Jason Lee Hayes
Active member
- Local time
- Today, 19:59
- Joined
- Jul 25, 2020
- Messages
- 174
I am using some code that simply populated a table when a form is opened and closed which populated some fields. I am trying to insert the current value of a TempVar declaired as [TempVars]!TempLogonName] to the field UserName however i cannot seem to get the formatting write. The TempVar holds a String Value. I thing i may have not enough or too many Speech Marks in the line below but being playing with it and tried many versions including usning it through some of those free online SQL checkers but non identify the error. Any help would be very much appreciated... Thanks in advance..
If i take the following bit out it works some likely be something with this bit I'm sure:-
My TempVar Value is returning what is expected (The name of the current user) eg "Joe Bloggs" and my TempVar works everywhere else...
If i take the following bit out it works some likely be something with this bit I'm sure:-
Code:
AND (tblDataChanges.UserName = """ & [TempVars]![TempLogonName] & """)"
My TempVar Value is returning what is expected (The name of the current user) eg "Joe Bloggs" and my TempVar works everywhere else...
Code:
strSql = "SELECT tblDataChanges.* FROM tblDataChanges WHERE ((tblDataChanges.DocTypeID = " & lngObjType & ") AND (tblDataChanges.DocName = """ & strDoc & ") AND (tblDataChanges.UserName = """ & [TempVars]![TempLogonName] & _
""") AND (tblDataChanges.DocHWnd = " & lngHWnd & ") AND (tblDataChanges.CloseDateTime Is Null) AND (tblDataChanges.OpenDateTime <= Now())) ORDER BY tblDataChanges.OpenDateTime, tblDataChanges.LogID;"