PDA

View Full Version : Macro to Run a Mail Merge



Denniz79
06-22-2004, 03:21 AM
Regarding this post:

http://www.vbaexpress.com/forum/showthread.php?t=314


To open the .doc from a form in the db, I'd use the Follow Hyperlink method in the Onclick event of a button.

Application.FollowHyperlink "c:\My Documents\mymerge.doc", , True, True

HTHI've got the same problem. Mine is the following, please help me. I have two tables with seperate id-numbers, after deletions, additions etc. they are not synchronical anymore. So when we do a mailmerge we don't have enough by only filling in the number of the record/or id.

We really want to have a button in the Access form, which opens the selected .doc in Word and most important of all, the selected RECORD.

Can you help me?

SJ McAbney
06-22-2004, 03:25 AM
I have two tables with seperate id-numbers, after deletions, additions etc. they are not synchronical anymore.
If you have two tables whereby their primary keys are synchronised then it suggests that your database design is not normalised meaning that you have a flawed structure.

Why do you have two "synchronised" primary keys? :confused:

Denniz79
06-22-2004, 03:28 AM
If you have two tables whereby their primary keys are synchronised then it suggests that your database design is not normalised meaning that you have a flawed structure.

Why do you have two "synchronised" primary keys? :confused:
I have a table with customers, with primary the customerID and a table with reservations with as primary ReservationsID. When i delete a reservation, then the autonumber keeps following, as well as the customerID. Understand?

Can you help me?

SJ McAbney
06-22-2004, 03:52 AM
You need a junction table as you have a many to many relationship that you have not modelled.

Your junction table should consist of two fields: CustomerID and RerservationsID. Both of these should be of the Number data type. They are both foreign keys and should be related to your Customers and Reservations table by the respective primary key. Now, to keep this unique, these two foreign keys should be selected together in order to create this new table's composite (primary) key.

Denniz79
06-22-2004, 03:56 AM
You need a junction table as you have a many to many relationship that you have not modelled.

Your junction table should consist of two fields: CustomerID and RerservationsID. Both of these should be of the Number data type. They are both foreign keys and should be related to your Customers and Reservations table by the respective primary key. Now, to keep this unique, these two foreign keys should be selected together in order to create this new table's composite (primary) key.
Ok, but what is going wrong when i then delete a customer or a reservation?
This isn't my question, i want to have a button in Access from where it starts up Word and (or when it's already open) open the selected .doc and as i said most important the SELECTED record, so we can check it and e-mail it.

You know how?

Anne Troy
06-22-2004, 03:57 AM
Hi, guys. I broke this off from the other thread. :)

Anne Troy
06-22-2004, 04:02 AM
Denniz: It sounds like we need to *build* a document name from the record information. I assume you don't HAVE a hyperlink already, you want to create one that opens the appropriate record. You'll have to let us know what method you have used for the file names of the Word documents and how they relate (syntax) to your Access database record's field names.

(I think)

Imdabaum
07-02-2008, 03:32 PM
:dunnoI don't mean to hi-jack this thread, but did anyone figure out how to open the word document and set the parameters from Access?

I have a application that prints contracts for real estate sales and purchases. The original developer built a report formatted to fit the designs of the Real estate agents based on a query that is built strictly in VBA. There are three tables that are joined; properties, specialProvisions, and amendments for changes to the contract.

Paragraphs are inserted into the SQL creating a huge problem when it comes to Access's limit of 64k characters. Yes amazingly enough we exceed that more often than not now as simple formatting tags alone that were placed in it take up 36K. Add infinite number of memo fields that store special provision information and then amendments and it builds fast. As a solution, I created a word document that held all the standard phrasing that was independent of the data and have put the mailmerge fields into the document to simply insert the necessary data.

Now my question is the same as Denniz's. Can I open it from VBA and only open the .doc for the current record in the form?:banghead: I don't want to open the .doc and make the users search through the MailMerge doc for the ID (which is invisible to them on the form)

Imdabaum
07-08-2008, 10:10 AM
Didn't figure out how to do it directly from the query in Access but did some exporting into Excel and set the data source from there like the KB article posted on this site.