Jumat, 06 Oktober 2017

RE: [MS_AccessPros] Syntax error in INSERT INTO statement.

 

Hi Art

You need to delimit SQL dates with hash/pound signs (#) not quotes, and they need to be formatted in a particular way.  However, in your case you wish to insert the current date and time, and SQL understands the Now() function, so you don't need to substitute its value and delimit it.

Try this:

strSQL = "INSERT INTO Logs (UserId, Date, Operation) Values ('" & gstrThisUser & "',Now(),'" & Activity & "')"

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, 7 October 2017 09:24
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Syntax error in INSERT INTO statement.

 

 

I am receiving the following error when I run the function below:

Syntax error in INSERT INTO statement.

 

This is the call to the function:

 modUtilities.LoggingActivity "Successfully logged in"

 

The function defined:

 

 Public Sub LoggingActivity(Activity As String)
 Dim strSQL As String
 strSQL = "INSERT INTO Logs (UserId, Date, Operation) Values ('" & gstrThisUser & "','" & Now() & "','" & Activity & "')"
  CurrentDb.Execute "INSERT INTO Logs (UserId, Date, Operation) Values ('" & gstrThisEmpName & "','" & Now() & "','" & Activity & "')"
  End Sub


  Contents of strSQL:

INSERT INTO Logs (UserId, Date, Operation) Values ('admin','10/6/2017 3:22:31 PM','Successfully logged in')

 

And for the life of me that looks like it should work....

 

Any ideas?

 

Thank you,

Art Lorenzini

SD

 


  

__._,_.___

Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar