Undefined Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In Form1, there is combo1 which displays 3 columns to help with solution. A
button opens up Form2 where is combo2 and combo2 is to select records based
on column3 of combo1 in Form1.

My code looks something like this:

Me.combo2.RowSource = "SELECT lngPINo, txtPIRefNo, lngCustNo FROM _
tblProformaInvoice WHERE lngCustNo = [Forms]![Form1]!combo1.Column(2)"

Unfortunately, everything on click on combo2 on Form2 (Form1 is opened, of
course), I get the error: Undefined function '[Forms]![Form1]!combo1.Column'
in expression. Is there something wrong with the code? Thanks.
ck
 
Try putting the reference to the form field outside of the quotes:

Me.combo2.RowSource = "SELECT lngPINo, txtPIRefNo, lngCustNo FROM _
tblProformaInvoice WHERE lngCustNo = " & [Forms]![Form1]!combo1.Column(2)

That assumes lngCustNo is a numeric value (which seems reasonable, given its
prefix). If it were a text fields, you'd also need to add quotes:

Me.combo2.RowSource = "SELECT lngPINo, txtPIRefNo, lngCustNo FROM _
tblProformaInvoice WHERE lngCustNo = " & Chr$(34) &
[Forms]![Form1]!combo1.Column(2) & Chr$(34)
 
Back
Top