472,981 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,981 software developers and data experts.

Add Current Date To Table After Mail Merge

Hi Everyone,

Access 2000

I have some code behind a button that performs a word merge with a query
data source. The merge works fine. But what I'd like to do somehow is
after the merge is generated (or before), assign the current date to the
[LetterDate] field in the main table [tblAdm] the query data source is based
on. Is this even possible? If so, how could I do it? Here is the code
that works so far:

Private Sub cmdLetter_Click()
Dim objWord As Word.Document
Set objWord = GetObject("K:\DATA\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource Name:="K:\DATA\ADM.mdb",
LinkToSource:=True, Connection:="QUERY qryLetter"
' Execute the mail merge.
objWord.MailMerge.Execute
End Sub

Thanks for your help,

William
Nov 12 '05 #1
2 3192
The simplest way would be to design an update query and run the query after
the merge is complete. In the update query just add the [LetterDate] field
to the design grid. Select the main menu/Query/Update Query option. In the
Update To: type in "Date() " (no quotes). If your query is called
qupdLetterDate add the following to the end of your procedure:
Private Sub cmdLetter_Click()
Dim objWord As Word.Document
Set objWord = GetObject("K:\DATA\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource Name:="K:\DATA\ADM.mdb",
LinkToSource:=True, Connection:="QUERY qryLetter"
' Execute the mail merge.
objWord.MailMerge.Execute
DoCmd.OpenQuery "qupdLetterDate", acNormal, acEdit
End Sub
If you only want to add today's date to new records open the table that
contains the LetterDate field and set the Default value to Date().

Hope this helps!
--
Reggie

www.smittysinet.com
----------
"William Wisnieski" <ww********@admissions.umass.edu> wrote in message
news:40********@news-1.oit.umass.edu... Hi Everyone,

Access 2000

I have some code behind a button that performs a word merge with a query
data source. The merge works fine. But what I'd like to do somehow is
after the merge is generated (or before), assign the current date to the
[LetterDate] field in the main table [tblAdm] the query data source is based on. Is this even possible? If so, how could I do it? Here is the code
that works so far:

Private Sub cmdLetter_Click()
Dim objWord As Word.Document
Set objWord = GetObject("K:\DATA\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource Name:="K:\DATA\ADM.mdb",
LinkToSource:=True, Connection:="QUERY qryLetter"
' Execute the mail merge.
objWord.MailMerge.Execute
End Sub

Thanks for your help,

William

Nov 12 '05 #2
Thanks for your help....that works!
"Reggie" <no**********@smittysinet.com> wrote in message
news:6Y********************@comcast.com...
The simplest way would be to design an update query and run the query after the merge is complete. In the update query just add the [LetterDate] field to the design grid. Select the main menu/Query/Update Query option. In the Update To: type in "Date() " (no quotes). If your query is called
qupdLetterDate add the following to the end of your procedure:
Private Sub cmdLetter_Click()
Dim objWord As Word.Document
Set objWord = GetObject("K:\DATA\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource Name:="K:\DATA\ADM.mdb",
LinkToSource:=True, Connection:="QUERY qryLetter"
' Execute the mail merge.
objWord.MailMerge.Execute


DoCmd.OpenQuery "qupdLetterDate", acNormal, acEdit
End Sub


If you only want to add today's date to new records open the table that
contains the LetterDate field and set the Default value to Date().

Hope this helps!
--
Reggie

www.smittysinet.com
----------
"William Wisnieski" <ww********@admissions.umass.edu> wrote in message
news:40********@news-1.oit.umass.edu...
Hi Everyone,

Access 2000

I have some code behind a button that performs a word merge with a query
data source. The merge works fine. But what I'd like to do somehow is
after the merge is generated (or before), assign the current date to the
[LetterDate] field in the main table [tblAdm] the query data source is

based
on. Is this even possible? If so, how could I do it? Here is the code
that works so far:

Private Sub cmdLetter_Click()
Dim objWord As Word.Document
Set objWord = GetObject("K:\DATA\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource Name:="K:\DATA\ADM.mdb",
LinkToSource:=True, Connection:="QUERY qryLetter"
' Execute the mail merge.
objWord.MailMerge.Execute
End Sub

Thanks for your help,

William


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Dauria | last post by:
What I am trying to do is write a resume into a word document from information in an Access database. I have been using bookmarks and inserting table results into the document and so far it's...
8
by: Ishbel Kargar | last post by:
Since upgrading from old laptop (Windows 98) to new laptop (Windows XP), my mail-merge letters are doing strange things with date formats. For instance, my reminder letter for lapsed subs carries...
1
by: Lisa | last post by:
I have a query named QryDept where one of the fields is DeptID. The query is used for the data source of a mail merge letter. I would like to control which department is to get the mail merge...
7
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which...
1
by: scott | last post by:
Hi Everyone, I don't know if this is the correct forum but I thought i'd ask. I have an access DB with a function to automatically safe a table with fields i'm mail merging into MS Word. Word...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
7
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
1
by: beechclose | last post by:
I have an form in Access which runs a make-table query and then mail merges the contents to Word. One of the merged fields is a date - in Access the date appears in 'UK' format correctly but when...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.