If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Mail merge using Albert Kallal
Hi,
I am using source code from Albert Kallal mailmerge to insert data from an Acces form to a word template. It works perfectly except for I have a combo box to select the company, form displays the company name but the bound item on the form is the companyID from a seperate table. When I perform the merge only the companyID number is displayed and not the actual company name. Any sujestions would be a great help. -- Jens |
#2
|
|||
|
|||
Mail merge using Albert Kallal
What you need to do in this case is build query.
So what you do is fire up the query builder, and drop in your first table. now drop in the table with a company. now simply draw join line from that companied field to the company table. For your query, simply drag the "*" from the 1st table into the query grid. And, then drag and drop the company name from the 2nd table into the query grid. (save this query...*TRY* the query...make sure it works ok... Now, in your form, behind the button go: me.refresh dim strSql as string strSql = "select * from NameOfYourNewQuery where id = " & me!id MergeAllWord strSql The test I'm using the command called MergeAllWord. this allows you to specify any SQL that you create in the query builder for the merge. however, if we don't restrict it to the current records ID, that it would merge all records in the database, and I don't think you want that. Note in the above for the current record or form you were on, I'm assuming that your primary key is "id", so if your primary key for the current record form is different, then simply change the "id" in where id = " & me!id To whatever you're currently using. do note that if you have several lookups (combo box etc) in your current form where the ID is displayed, but you want the actual text description from another table, you can drag and drop as many tables as you want into the above query. do remember to double click on the "join" line that you just drew between the tables, and ensured that it is a left join (otherwise, records without a company name will not appear in this query, and it will not work). -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada |
#3
|
|||
|
|||
Mail merge using Albert Kallal
Thaks for the reply, worked straight away
-- Jens "Albert D. Kallal" wrote: What you need to do in this case is build query. So what you do is fire up the query builder, and drop in your first table. now drop in the table with a company. now simply draw join line from that companied field to the company table. For your query, simply drag the "*" from the 1st table into the query grid. And, then drag and drop the company name from the 2nd table into the query grid. (save this query...*TRY* the query...make sure it works ok... Now, in your form, behind the button go: me.refresh dim strSql as string strSql = "select * from NameOfYourNewQuery where id = " & me!id MergeAllWord strSql The test I'm using the command called MergeAllWord. this allows you to specify any SQL that you create in the query builder for the merge. however, if we don't restrict it to the current records ID, that it would merge all records in the database, and I don't think you want that. Note in the above for the current record or form you were on, I'm assuming that your primary key is "id", so if your primary key for the current record form is different, then simply change the "id" in where id = " & me!id To whatever you're currently using. do note that if you have several lookups (combo box etc) in your current form where the ID is displayed, but you want the actual text description from another table, you can drag and drop as many tables as you want into the above query. do remember to double click on the "join" line that you just drew between the tables, and ensured that it is a left join (otherwise, records without a company name will not appear in this query, and it will not work). -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada |
Thread Tools | |
Display Modes | |
|
|