I have the following code:
It runs fine when fldName doesn't include a space (ex: UserID), but I get the following error when the field has a space in the name, as shown above. What is the likely simple piece of syntax I'm missing here?
Error: "Run-time error '3075': Syntax error (missing operator) in query expression 'User ID'."
Code:
tblName = "TableA"
fldName = "User ID"
sqlStr = "SELECT " & fldName & " FROM " & tblName & " WHERE '" & fldName & "' = '" & rs1.fields("Username") & "'"
Set rs1 = currentdb.openrecordset(sqlStr)
It runs fine when fldName doesn't include a space (ex: UserID), but I get the following error when the field has a space in the name, as shown above. What is the likely simple piece of syntax I'm missing here?
Error: "Run-time error '3075': Syntax error (missing operator) in query expression 'User ID'."