View Single Post
  #1 (permalink)  
Old December 4th, 2003, 11:32 AM
cpopham cpopham is offline
Authorized User
Join Date: Dec 2003
Location: , WV, USA.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 2002 VBA with SQL using a variable

Hello everyone,

I am new to this forum. I can not seem to find an answer anywhere. I know that you can use a variable in vba with sql, however, this is my code:

Option Compare Database
Option Explicit

Dim strSaveAs As String
Dim strSQL As String

' Set SQL variable to SQL statement
     strSQL = "INSERT INTO TblAccessDate ([Date],[TableName])" & _
              "VALUES (Date(), ' & strSaveAs & ');"
' Run SQL Statement
DoCmd.RunSQL strSQL

Okay the statement part to insert a date into the table works fine, but I can not get the INSERT INTO statement to pass the variable to the table also. I am basically using the table to see what date and what file was created when a user runs this code. I have tried a few different way of trying to accomplish this. Any ideas???

Thanks, Chester
Reply With Quote