Results 1 to 4 of 4
  1. #1
    lizzywu is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    41

    Return date from Word to Access


    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.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    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.

  3. #3
    lizzywu is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    41
    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.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Return DLookup result as date?
    By kman42 in forum Access
    Replies: 8
    Last Post: 04-22-2011, 11:35 AM
  2. Query to return only the row containing the highest date.
    By eric.opperman1@gmail.com in forum Queries
    Replies: 4
    Last Post: 03-22-2011, 08:42 PM
  3. Query return for date ranges.
    By Desstro in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 06:44 AM
  4. return last updated date for each product
    By jonnyuk3 in forum Queries
    Replies: 0
    Last Post: 06-17-2009, 04:38 AM
  5. Replies: 1
    Last Post: 12-21-2005, 12:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums