Mail Merge from Access Database Table based on specific record

randolphoralph

Registered User.
Local time
Today, 15:15
Joined
Aug 4, 2008
Messages
101
I am not sure where to begin to make this work and any help would be greatly appreciated.

I have a access table name Customers. The table has 4 fields customer number, name, address, and phone number.

I have a letter in microsoft word titled Welcome Letter that I would like to be filled in based on the current record/customer being viewed.

The access form contains a button that I would like the user to click to open the word doc and fill in the customer number, name, address, and phone number.

First off, I am not sure how to have the button accomplish this.

Secondly, In the word doc do I just set it up using the normal mail merge or is there something else that needs to be done?

I have used mail merge before but not in combination with access.
 
Here is what I have so far.

The command button
Code:
Private Sub SendWelcomeLetter_Click()
MergeIt
End Sub

Code:
Function MergeIt()
   Dim objWord As Word.Document
   Set objWord = GetObject("E:\Customers.doc", "Word.Document")
   ' Make Word visible.
   objWord.Application.Visible = True
   ' Set the mail merge data source as the Northwind database.
   objWord.MailMerge.OpenDataSource _
      Name:="E:\Customers.mdb", _
      LinkToSource:=True, _
      Connection:="TABLE Customers", _
      SQLStatement:="SELECT * FROM [Customers]"
   ' Execute the mail merge.
   objWord.MailMerge.Execute
End Function

When I click on the button it opens word and I receive a window that says Data Link Properties. There are 4 tabs Provider, Connection, Advanced, and All.

Under Provider I have Microsoft Jet 4.0 OLE DB Provider selected. Under Connection it has the link to the database and E:\Customers.mdb and it has the information to log on to the database...By default the Username is Admin and a password field which is blank. (The database itself is not set to have a username or password.) If I click the ok button on the Data Link Properties window I receive the following error message.

"The database has been placed in a state by user 'Admin' on machine '125FGAE' that prevents it from being opened or locked. After I click the Ok button on the error message it shows a login window asking for the Username and Password again. I hit the Ok Button and a word document appears with the information filled in from the database.

What do I need to do so that it is not giving the error message?
 
firstly why do this as a mail merge - let accress do a report for you ..

secondly check the samples on how to do this - my preferd method is the Super easy word d/b
otherwise you get in to bookmarks (check these as well)
 
I agree that you can do a lot with Aces reports. I do lots of "letters" with acess reports.

If you do to do some very "fancy" formatting then Word is they way.
See: Super Easy Word Merge. Note: You will need to scroll done to find it.
 

Users who are viewing this thread

Back
Top Bottom