Date/Time Stamp

From: Bmistry (Bmistry_at_discussions.microsoft.com)
Date: 03/15/05


Date: Tue, 15 Mar 2005 11:37:11 -0800

Hi,

I have some code set up to run a process that opens a a word document (mail
merge) and connects to a query as the datasource. As part of this process I
would like for a field in the query to be updated with the current date/time
stamp, so the system knows that the process has been run for that record.

I have tried using the SetValue in a macro but it seems to only work if I
point it to a field on a form. I cannot use this method as it is only the
records on the query that I would like to set with the Date/Time and not
every record in my form.

Any help is much appreciated.

This is my code so far:

Private Sub OpenWord_Click()
'On Error GoTo Err_OpenWord_Click

'Word Objects
Dim appWd As Word.Application
Dim docWd As Word.Document
Dim selWd As Word.Selection

'Start running Word in background
Set appWd = New Word.Application
appWd.Visible = True 'Make it visible
appWd.WindowState = wdWindowStateMaximise
Set docWd = appWd.Documents.Open("\\Cagtafsr02\HR\NAT Human Resources\KPMG
HR Operations\HR Systems\Applications\Databases\Encore\New Encore
DB\Communications\ApprovalLetterMerge_Template_v2.doc") 'Open a document

docWd.MailMerge.MainDocumentType = wdFormLetters
    docWd.MailMerge.OpenDataSource Name:= _
        "\\Cagtafsr02\HR\NAT Human Resources\KPMG HR Operations\HR
Systems\Applications\Databases\Encore\New Encore DB\Encore.mdb" _
        , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
        Format:=wdOpenFormatAuto, Connection:= _
        "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=\\Cagtafsr02\HR\NAT Human Resources\KPMG HR Operations\HR
Systems\Applications\Databases\Encore\New Encore
DB\Encore.mdb;Mode=Read;Extended Properties="""";Jet OLEDB:System
database="""";J" _
        , SQLStatement:="SELECT * FROM `qry_ApprovalLetter`",
SQLStatement1:="", _
        SubType:=wdMergeSubTypeAccess

Exit_COpenWord_Click:
Exit Sub
    
End Sub



Relevant Pages

  • Waiting for MSAccess to execute DDE commands
    ... Excel and Access and the Word mail merge document just hangs. ... Can you convert the query to a make table query and then use that table as ... > When I open the Word document, Access opens and I get the login screen for ... > I have moved both the Access database and Word document to my local drive ...
    (microsoft.public.word.mailmerge.fields)
  • Opening Word document via code... having issues...
    ... records from my Access database into a Word document. ... my query is using user input as criteria. ... Private Sub openDoc ... The file opens fine, ...
    (microsoft.public.access.formscoding)
  • Word doc wont open properly with VB Code
    ... records from my Access database into a Word document. ... my query is using user input as criteria. ... Private Sub openDoc ... The file opens fine, ...
    (microsoft.public.access.formscoding)
  • Re: Mailmerge from Access
    ... > specifically directs you to open a word document, ... > introduce a parameter into the MS query. ... >> manipulate the z-order (i.e. which window in front of which) will work. ... >>> So the problem is that the queries parameter window opens up first, ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Merging data from Access Query
    ... merged into a word document, I get the SQL message about merging data into ... I have re-established the links from the query to the table fields, ... the SQL information inside of word to make sure everything is right for the ... to merge the fields from the access database query, ...
    (microsoft.public.word.mailmerge.fields)