SQl statement in VBA

chrisjames25

Registered User.
Local time
Today, 13:59
Joined
Dec 1, 2014
Messages
404
Hi I am trying to create a listbox rowsource on the fly once a command button is pressed in a form.

My problem is i literally dont understand how to write sql into vba.

Code:
SELECT Tbl_Pot_Size.ID, Tbl_Pot_Size.PotName, Qry_VarietyFilter.PotSize_ID
FROM Tbl_Pot_Size RIGHT JOIN Qry_VarietyFilter ON Tbl_Pot_Size.ID = Qry_VarietyFilter.PotSize_ID
ORDER BY Tbl_Pot_Size.ID;

NO clue where i need to put " or ' i thought i would just wrap the whole thing in "" and sorted but not such luck.

Any advice, guidance, link to usual sources would be much appreciated.

CHeers
 
What is Qry_VarietyFilter ? Suggest you post the sql.
 
try

me.lstbox.rowsource="SELECT Tbl_Pot_Size.ID, Tbl_Pot_Size.PotName, Qry_VarietyFilter.PotSize_ID" & _
" FROM Tbl_Pot_Size RIGHT JOIN Qry_VarietyFilter ON Tbl_Pot_Size.ID = Qry_VarietyFilter.PotSize_ID" & _
" ORDER BY Tbl_Pot_Size.ID"

note the spaces at the start of the last two lines
 

Users who are viewing this thread

Back
Top Bottom