Data problem - Please help!!!!!

abezuide

Registered User.
Local time
Yesterday, 23:17
Joined
May 7, 2004
Messages
30
I am using a query in my code
ssql5 = "select * from [my table] " _
& "where [my field1] = " & rstmyrecordset![my field1] _
& " and [my field2] = " & rstemyrecordset![my field2]

I then open the recordset like this
Set rsttemp = dbscurrent.OpenRecordset(ssql5, dbOpenDynaset)

My problem is that my data has brackets like this
rstmyrecordset![my field1] = blue(s)

I get a runtime error 3075 that says: invalid use of '.','!' or '()' in query expression. However, this is a user database and I cannot change the way their data looks. Is there any way I can make access read the brackets in the data without giving me an error?
 
I don't think the problem is caused by the brackets.

Since [my field1] is a text field, you need to surround its value by quotes. If [my field2] is also a text field, its value need to be surrounded by quotes, too,

You can use a message box to display the SQL string to see if it is correct, e.g.
Code:
ssql5 = "select * from [my table] " _
       & "where [my field1] = '" & rst![My Field1] & "'" _
       & " and [my field2] = '" & rst![My Field2] & "'"
       
MsgBox ssql5
 

Users who are viewing this thread

Back
Top Bottom