Inserting Data into a table

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

Hi,

I'm trying to insert today's date into a field every time
the code is run. I have the following code, which
currently doesn't do anything when run.

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblLastUpdate")
rst.AddNew
rst("lastupdate") = Date ()
rst.Close
dbs.Close

LastUpdate is the name of the field.

Thanks in advance for your help.
Doug
 
You're missing just one tiny important detail. You did not include the "Update" statement to tell
Access to actually update the record. Try this:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblLastUpdate")
rst.AddNew
rst("LastUpdate") = Date
rst.Update
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing
 
Jeff,

That did it. A bit of an oversight on my part. Thanks
for the help.

Doug
-----Original Message-----
You're missing just one tiny important detail. You did
not include the "Update" statement to tell
 
Back
Top