I have a print date in my word file, and once I print the file, it will generate a specific date. I'd like the date to be automatically returned to an Access table. Is there any way to perform that?
Thank you very much.
I have a print date in my word file, and once I print the file, it will generate a specific date. I'd like the date to be automatically returned to an Access table. Is there any way to perform that?
Thank you very much.
Use VBA code to set connection to the Access database and run SQL UPDATE or INSERT statement.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
June, I was wondering whether you can offer some detailed coding for my reference because I don't really know VBA code.
I attach my files here, one with access table and form, and the other is my word file, which has the print date.
Many thanks.
I have never done coding behind Word document, so have no idea how to grab the date from document nor how to dynamically identify the record ID in database to update. Using current date is easy.
You might review this tutorial http://msdn.microsoft.com/en-us/library/ff604039.aspx.
I put this procedure behind the document. When I manually run it the date is saved to table for the designated record. Need to set VBA library reference for Microsoft ActiveX Data Objects 2.8 Library. I don't know how to automate procedure execution.
The word document must be saved as a macro-enabled file.Code:Sub SaveDate() Dim cn As ADODB.Connection Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\GetDate\GetDate.accdb;Persist Security Info=False" cn.Execute "UPDATE Tcustomer_info SET print_date = Date() WHERE customerID = 1" cn.Close Set cn = Nothing End Sub
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.