Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Append records to table from a Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jologs - 16 Jul 2005 04:32 GMT
Hi:

I created a tblLog to tract the users which has "Username"(captured
NetID) and "Date"(=now).

I created a frmSwitchboard bounds to tblLog and add the "txtUsername"
and "txtDate". I got an error using the codes below "Syntax error in
INSERT INTO statement". I'm a beginner and don't know how to properly
execute a query.  Thanks.

Private Sub Form_Close()

   Dim stDocName As String
   Dim strSQL As String

   strSQL = "INSERT INTO tblLog (Username,Date) VALUES ('" &
txtUserName & "', '" & txtDate & "');"
   stDocName = "Switchboard"

   If Me.txtCountUserName.Value = 0 Then
       DoCmd.OpenForm "frmUnauthorizedUser"
   Else
   CurrentDb.Execute strSQL
   DoCmd.OpenForm stDocName
   End If
   
End Sub
Ronald Roberts - 16 Jul 2005 07:10 GMT
The date needs # signs around it, not quotes.
Try using Date() and not Now().
Date is a reserved word, I wouldn't use it as a field name.

strSQL = "INSERT INTO tblLog (Log_Username, Log_Date) VALUES ('" &
 txtUserName & "', #" & txtDate & "#);"

Ron

> Hi:
>
[quoted text clipped - 23 lines]
>    
> End Sub
Jologs - 16 Jul 2005 08:37 GMT
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.