ComboBox RowSource Syntax

JuniorWoodchuck24

Registered User.
Local time
Today, 14:11
Joined
Jan 13, 2010
Messages
59
Have the following code and it seems to be giving me an error

cboEquipmentName.RowSource = "SELECT ID, EquipmentName & ' ' & TagNumber" & _
" FROM " & TotalStr & _
" WHERE ProjID = " & StrProj & _
" ORDER BY EquipmentName;" cboEquipmentName.Requery

TotalStr is a defined variable and so is StrProj within the forms code. I'm getting a blank box when I go to pull down.
 
Last edited:
I'd say it was the & ' ' & bit. What are you trying to achieve there?
 
cboEquipmentName.RowSource = "SELECT ID, EquipmentName & ' ' & TagNumber" & _
" FROM " & TotalStr & _
" WHERE ProjID = " & StrProj & _
" ORDER BY EquipmentName;"
cboEquipmentName.Requery

The ' ' is a empty space between the fields EquipmentName and TagNumber. I think the error is coming from the WHERE part. When I use the following code everything works, but I need the WHERE part to use as a Filter

cboEquipmentName.RowSource = "SELECT ID, EquipmentName & ' ' & TagNumber" & _
" FROM " & TotalStr & _
" ORDER BY EquipmentName;"
cboEquipmentName.Requery
 
Strproj is a string right? You need to encapsulate it in quotes for it to work, so:
Code:
" WHERE ProjID = '" & Strproj & "'" & _
 

Users who are viewing this thread

Back
Top Bottom