Undefined Function

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
 
D

Douglas J. Steele

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top