Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set row source for list box in vba code?

Status
Not open for further replies.

xq

Programmer
Jun 26, 2002
106
NL
i was trying set row source by sql string in vba code for a list box, why when i open it, there is nothing, i use the same way to set up row source for combo box, it works fine, or the list box is different with combo box?

the code is:

Me!lstResult.RowSource = "SELECT Invoice.ID " & _
"FROM Invoice WHERR " & _
"Invoice.ID = " & & _
Form_SearchcmbInvoiceID

really appreciate for any help!!!
 
Hi

Not sure if errors are actually in the code or just in what you copied here, But

Me!lstResult.RowSource = "SELECT Invoice.ID " & _
"FROM Invoice WHERR " & _
"Invoice.ID = " & & _
Form_SearchcmbInvoiceID

Me!lstResult.RowSource = "SELECT Invoice.ID " & _
"FROM Invoice WHERE " & _
"Invoice.ID = " & _
Form_SearchcmbInvoiceID

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reay@talk21.com
 
Hi,
If InvoiceId is a number, then try using the Val function to convert it into a number like:

Me!lstResult.RowSource = "SELECT Invoice.ID " & _
"FROM Invoice WHERE " & _
"Invoice.ID = " & & _
Val(Form_SearchcmbInvoiceID)

Me.lstResult.Requery Hope it helps. Let me know what happens.
With regards,
PGK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top