Peter Bellamy
Registered User.
- Local time
- Today, 18:52
- Joined
- Dec 3, 2005
- Messages
- 295
Merry Christmas !!
I think I must have had too much Christmas cheer as I can't get the syntax correct for this SQL statement I am modifying.
I want the variable (Me.product_choice) from the form that kicked off the code to be read in the SQL but I don't seem to be able to crack it.
StrSQL = "INSERT INTO [" & strTxtFile & " Data Label Numbers] IN 'd:\Database\Product Serial No Records.mdb' " & _
"SELECT " & strTbl & "." & strRec & "customer AS Customer, " & strTbl & "." & strRec & "product_type AS Product," & strTbl & "." & strRec & "serialno AS SerialNo, Product.product_friendlyname AS Friendly, Product.product_weight As Weight, Product.product_code AS Code " & _
"FROM " & strTbl & " LEFT JOIN Product ON " & strTbl & "." & strRec & "product_type = Product.product_name " & _
"WHERE (((" & strTbl & "." & strRec & "date_datalable) Is Null) AND ((" & strTbl & "." & strRec & "product_type) = " & "' Me.product_choice '" & ")) " & _
"ORDER BY " & strTbl & "." & strRec & "serialno;"
The statement worked fine before when it was had hard coded in, but I now want the flexiblility of the varoiable it doesn't work !!
Cheers
I think I must have had too much Christmas cheer as I can't get the syntax correct for this SQL statement I am modifying.
I want the variable (Me.product_choice) from the form that kicked off the code to be read in the SQL but I don't seem to be able to crack it.
StrSQL = "INSERT INTO [" & strTxtFile & " Data Label Numbers] IN 'd:\Database\Product Serial No Records.mdb' " & _
"SELECT " & strTbl & "." & strRec & "customer AS Customer, " & strTbl & "." & strRec & "product_type AS Product," & strTbl & "." & strRec & "serialno AS SerialNo, Product.product_friendlyname AS Friendly, Product.product_weight As Weight, Product.product_code AS Code " & _
"FROM " & strTbl & " LEFT JOIN Product ON " & strTbl & "." & strRec & "product_type = Product.product_name " & _
"WHERE (((" & strTbl & "." & strRec & "date_datalable) Is Null) AND ((" & strTbl & "." & strRec & "product_type) = " & "' Me.product_choice '" & ")) " & _
"ORDER BY " & strTbl & "." & strRec & "serialno;"
The statement worked fine before when it was had hard coded in, but I now want the flexiblility of the varoiable it doesn't work !!
Cheers