Kjuib wrote:
>How do I get an Append Query to run from VB?
>My current code is:
> Dim dbs As Database
> Set dbs = OpenDatabase("J:\Backups\ClosingManager.mdb")
> dbs.Execute " INSERT INTO UpdateLog([Date], Area,
>Comment) VALUES(Now(), strArea, strComment);"
> dbs.Close
>
>strArea and strComment are Variables for Strings, but the
>Query will not run, but If I put the strings in there It
>will run... what can I do differently?
You need to put the strings in the SQL statement, but you
can get an expression to do it for you:
strSQL = " INSERT INTO UpdateLog([Date], " _
& "Area, Comment) VALUES(" _
& Format(Now(), "\#m\/d\/yyyy h\:n\:s") & ", """ _
& strArea & """, """ & strComment & "");"
Debug.Print strSQL 'look at it in immediate/debug window
dbs.Execute strSQL, dbFailOnError
--
Marsh
MVP [MS Access]
|