I'm trying to record user logons with code run in the splash form. I could do it with a recordset but want to figure out why the following isn't working:
CODE:
[tt]
Dim strUserName As String
Dim strSQL As String
strUserName = Trim(apiUserName)
strSQL = "INSERT INTO tbl_Logons(UserName) " & _
"SELECT " & Chr(39) & strUserName & Chr(39) & " AS [UserName];"
txtUser = "Current User: " & strUserName
DoCmd.RunSQL strSQL
[/tt]
ERROR:
*Note the difference in the debug value of the strSQL variable between the check value while stepping and the error description returned--there's an extra quote on the left side of the variable.
I've tried with both CHR(34) and CHR(39)
Taking the strSQL from a breakpoint and running it from the query window works fine.
THANKS!
[tt]
?strsql
INSERT INTO tbl_Logons(UserName) SELECT "doejohn " AS [UserName];
?err.Number
3075
?err.Description
Syntax error in string in query expression '"doejohn'.
[/tt]