Im using the following code
[code=vb]
queerey = Replace(Text3, "or", "' or OrderID ='")
strSQL2 = "SELECT * FROM tblorder where orderID = '" & queerey & "'"
DoCmd.OpenRepor t "tblorder1" , acViewPreview, strSQL2
MsgBox strSQL2
[/code]
The idea is that the i can enter 1 or 2 for example and they will show in a report which i have got set up but when i output the string it comes out as
SELECT * FROM tblorder where orderID = '1 ' or orderID = ' 2'
which means that it wont work because of the spaces. I have tried it using
[code=vb]
strSQL2 = "SELECT * FROM tblorder where orderID = '1' OR orderID = '2'"
[/code]
and that worked and the only thing different is the spaces.
[code=vb]
queerey = Replace(Text3, "or", "' or OrderID ='")
strSQL2 = "SELECT * FROM tblorder where orderID = '" & queerey & "'"
DoCmd.OpenRepor t "tblorder1" , acViewPreview, strSQL2
MsgBox strSQL2
[/code]
The idea is that the i can enter 1 or 2 for example and they will show in a report which i have got set up but when i output the string it comes out as
SELECT * FROM tblorder where orderID = '1 ' or orderID = ' 2'
which means that it wont work because of the spaces. I have tried it using
[code=vb]
strSQL2 = "SELECT * FROM tblorder where orderID = '1' OR orderID = '2'"
[/code]
and that worked and the only thing different is the spaces.
Comment