Chris Miller
asked on
Access 2007 DoCmd.RunSQL Issue
I have an Access 2007 DB that has an Admin menu. On the admin menu I have macro buttons that will delete and update tables.
I have created a table "tbl_Uploads" with two fields. The first field lists all the tables that get updated. The second field is called "Timestamp".
How do I use the Run SQL to update the timestamp field for a given table listed in the tbl_Uploads.
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE()"
I have created a table "tbl_Uploads" with two fields. The first field lists all the tables that get updated. The second field is called "Timestamp".
How do I use the Run SQL to update the timestamp field for a given table listed in the tbl_Uploads.
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE()"
@CMILLER
what is your problem with the codes you posted?
docmd.setwarnings false
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE()"
docmd.setwarnings true
if your field "timestamp" Format is set to General Date(includes time), use Now() instead of Date()
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = Now()"
what is your problem with the codes you posted?
docmd.setwarnings false
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE()"
docmd.setwarnings true
if your field "timestamp" Format is set to General Date(includes time), use Now() instead of Date()
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = Now()"
ASKER
"tbl_Uploads" has two fields.
Field1 is Table Name (Lists the names of all my update tables)
Field2 is Timestamp (one row for each update table)
It works fine if all I have in my tbl_Uploads is just the Timestamp field but I have added a field that lists all my update table names.
So, when I update a table, I need the timestamp to populate Field1 for the correct table.
Field1 is Table Name (Lists the names of all my update tables)
Field2 is Timestamp (one row for each update table)
It works fine if all I have in my tbl_Uploads is just the Timestamp field but I have added a field that lists all my update table names.
So, when I update a table, I need the timestamp to populate Field1 for the correct table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am getting an error on the DoCmd.RunSQL
************************** ********** ********** ********** ********
Function ImportTechnicianTable()
Dim strFile As String
strFile = Environ("userprofile") & "\Documents\Import\Technic ians.xlsx"
'complete this line for the TransferSpreadsheet command
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDELETE-Technician Table"
DoCmd.TransferSpreadsheet acImport, 9, "Technicians", strFile, True, "Technicians!"
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE() WHERE Table Name="Technicians"
DoCmd.SetWarnings False
MsgBox "Technicians Table was updated!"
End Function
************************** ********** ********** ********** ********
**************************
Function ImportTechnicianTable()
Dim strFile As String
strFile = Environ("userprofile") & "\Documents\Import\Technic
'complete this line for the TransferSpreadsheet command
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDELETE-Technician Table"
DoCmd.TransferSpreadsheet acImport, 9, "Technicians", strFile, True, "Technicians!"
DoCmd.RunSQL "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE() WHERE Table Name="Technicians"
DoCmd.SetWarnings False
MsgBox "Technicians Table was updated!"
End Function
**************************
ASKER
See the attached
ASKER
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It Worked. Thanks.
CurrentDb.Execute "UPDATE tbl_Uploads SET tbl_Uploads.timestamp = DATE()"