sql problems

teiben

Registered User.
Local time
Today, 03:29
Joined
Jun 20, 2002
Messages
462
could some tell me what is the matter with this line of code?

INSERT INTO tblLog ( TheUser, TheReport, OpenDateTime ) " & _ " SELECT """ & fOSUserName() & """ AS TheUser, 'Report1' AS TheReport

'tbllog has the field theuser, thereport and opendatetime.
I'm trying to retrieve the UserName with which the user is logged into the network, using the function fOSUserName

I'm attempting to run this on the onopen event of report1
 
If that's the whole code, the quoting is all goofed up. Also, you have 3 fields in the first clause and only 2 in the second.
 
Just guessing here but your code should look something like:

DoCmd.RunSQL "INSERT INTO tblLog (TheUser, TheReport, OpenDateTime ) SELECT " & chr(34) & fOSUserName() & chr(34) & " AS TheUser, 'Report1' AS TheReport, Now() As OpenDateTime"

Regards,
Pete
 

Users who are viewing this thread

Back
Top Bottom