Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Merge 2 Access Database Into One


I want to find out how to Merge 2 Exactly the same Access Database(contains the same tables, each table contains the same field) into one BIG Access Database.

say, I have Database1 and Database2

Database1 has table "Qanswer" and "Qlist", Qanswer has fields of "Qid", "Qtext", Qlist has fields of "ListID", "LevelID"
Database2 has exactly the same stuff as Database1.

Now I want to Merge the two databases into a new one called Database3. so Database3 should have the same tables of Database1 and Database2. How to do that? any good way of doing it. (Database1 and Database2 are both quite big, each has at least 3000 records, I don't want to freeze the system when merging the two)

Thanks in advance




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Merge Two Access Database
Is there a program somewhere I can use to merge two access databases? I searched all over and found nothing. The two mdb's I need to merge are the same. But both contain records that have been altered.

Any help would be appreciated.

Thanks,

David

Merge Two Access Database Files From VB
I want to know how to merge two database files from vB

Merge Documents With Access Database
I have an Access database and want to generate a Word document with some fields from the database.
I'm working with Access97, Word 2000, windows 98.
So far I could merge single fields, but I need to send to word several related fields in the same letter.
Basically, I have a table with orders and another table with the products for each order. I need to generate a letter for each order that contains all of the products of the order.

How can I do that?

So far I can have the order's data into the letter, but don't know how to include all af the products in the same letter.

Please... HELP!!!

Access Database, Word Mail Merge... Need I Say More? =)
OK, long and comlicated....

basically I'm trying to mailmerge a current record to word. I have a query that finds the current record from the key on the form but when i try to mailmerge it word starts a new session of access and then, no surprise, the query prompts for the form field....

any idea how to get word to use the current session, or any other way of fixing it?

it occoured to me that i could get the windows userid with an API call and write it vs the table key value in another table... then the key number could be picked up in without the form open... but i think the chances of getting the query to pick up the userid are... well... slim...

any idea?

Can 2 Different Database Merge?
can 2 different database merge?

example:
database db5 merge with microsft access...

any SQL query need?

How To Create And Merge Database??!!
hello...

I'm quite new in vb..... can I know how can I create database......ok , I give my situation..... in my application, I got a command button which been used to select certain records (eg: street) in database and place the records into a new database... I mean the database is created and generated only when the records been selected by clicking the command button i told b4.... ok my next question is, how can I merge a record between two database....I mean I wanna replace some record in my second database to my first database (both database are same)....can some one help me??... I really blur on how to do it....

Mail Merge From Access
Hey guys,
I have an access db that basically serves as a frontend to a SQL database. I need to be able to create mailing labels from address information from within the database using the access frontend, what would be the best way to do this, a report in access or some type of word automation? I'm a bit over my head here...
Tom

Merge Snapshots In Access
hi guys,

ive got these reports i run and export daily, and i want to merge a coversheet into the .snp file.

is there a way in code to merge two completley differently formatted .snp files?

Thanks

Label Merge In Access
What code can I apply my mailing report to print the number of labels for each record based on a quantity field in my query? Example: Item number xxxxxxx hasa quantity of 35 and item number xxxxxxx has a quantity of 250. I want my merge to only print these quanties for each record.

Access Mail Merge
Hi,

I am merging excel data from an access application. I use this code:

Case 3
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "qryEmail", "N:DatabasesRestricted RemindersEmail_Data3.xls", True
MergeWord ("Reminder_Template_Email.doc")

I get the mail merged but certain records dont show properly. The dollar amount records dont show as $200.00 though it is in that format in the excel sheet (Email_Data3.xls as seen above) the access application creates. It merges in the mail as Amount Pledged – 200, 0, , , , , , , , , , , , , ,

I would appreciate if anyone would let me know what I need to do to set it right.

Thank you.

Lev

ANYONE, PLEASE? VBA: Access To Word Merge
I have developed an app (in Access 2002) that dynamically creates a
table, and the fields in that table, for propagation based on the max
number of occurences in a reference table. Basically, it runs all the
necessary selects to produce a 'flat file' that is used with the mail
merge (in Word 2002).

schema:
Name Address City ST Zip Zip4 Total Fund1 Legend1 Amount1 .... Fund(n) Legend(n) Amount(n)

My dilemma is, that the number of attributes will change daily, and I
had to create a static mail merge document because I'm not familiar
enough (at all) with Word objects to dynamcially create the merge with
a varying number of fields.

I'd like to be able to pass the largest number of occurrances, and
create the merge fields dynamically.

Below is the snippet that creates the table with a dynamic number of
attributes for each record. If someone could point me in the right
direction or offer a starting point on creating a mail merge the has
the same number of fields as the table, it would be much appreciated.

Sincerely,

beerman

'****************************************************************************
Code:
Sub mkTable(maxCount)

Dim db As Database
    Set db = CurrentDb
Dim tbl As TableDef
Dim fld As Field
Dim idx As Index

Dim i As Long

i = maxCount

Set tbl = db.CreateTableDef("newTable")
 
 With tbl
    .Fields.Append .CreateField("varID", dbLong)
    .Fields.Append .CreateField("varRefNum", dbLong)
    .Fields.Append .CreateField("varName", dbText)
    .Fields.Append .CreateField("varAmount", dbDouble)
    .Fields.Append .CreateField("varFlag", dbText)
        
        'Dynamically create the table fields based on the
max(CountOfOccurences)

        For i = 1 To maxCount
        
        .Fields.Append .CreateField("attrbA" & i, dbText, 150)
        .Fields.Append .CreateField("attrbB" & i, dbText, 150)
        .Fields.Append .CreateField("attrbC" & i, dbText, 150)
        .Fields.Append .CreateField("attrbD" & i, dbText, 150)
            
        Next i
  End With

db.TableDefs.Append tbl
db.TableDefs.Refresh

RefreshDatabaseWindow

'For debugging purposes
'MsgBox "The table:" & tbl.Name & " was created"

End Sub



Edited by - beerman on 9/28/2004 5:59:31 AM

Mail Merge From Access MDE File?
After getting side tracked on other projects, I am back to something I started a while ago. I need to dump about 180 fields of a table into a Word document from Access. I have this working in a couple of different ways, but I need to speed it up.

Method one just uses Bookmarks in a word .dot file and my code dumps the data in. For each record, I populate a temp doc, then copy/paste that doc onto a main totaldoc after performing a page break. This method is really slow. Some more info here.... http://www.xtremevbtalk.com/show...ght=Mail+Merge

For method two, I did some digging on Mail Merge, and set up a Word doc with the mail merge information. This method is working great, with less code for me to worry about and it seems to be running faster, as I assumed it might because I figured MS would have optimized for this feature more than my own code obviously.

However, I need convert this Access DB to a MDE file do to the amount of code it contains that I would like to keep private. Once I do this, it breaks. Office 2000 opens a "locked for editing" box wanting me to choose "ready only" or "Notify". Then, it shows a mess of garbled text on another screen and asks me to select the delimiter. Office XP works, but spits out a zero on each of most of the blank fields. Neither are acceptable.


Since I need to MDE my database, is Mail Merge even possible? Or, is there some code I can drop in my Mail Merge function to handle MDE's?

I am basicall using this code to Mail Merge ...

http://www.mvps.org/access/bugs/bugs0011.htm


Thanks in advance

Access To Word Merge Question
I know how to perform a mail merge from Access to Word using VBA. What I was wondering if anyone could tell me how to close the data source that the merge opens.

Such as ...
I have the following code:

Code:
.ActiveDocument.MailMerge.OpenDataSource Name:=databasepathname, _
ReadOnly:=False, LinkToSource:=False, AddToRecentFiles:=False, _
SQLstatement:=SQLstatement, openexclusive:=True, SubType:=wdMergeSubTypeWord2000

After it performs all the merges, it will leave the database that it used as the data source name. There will then be two instances of Access open on the users computer. I looked in the object browser within vba and there was a property for .mailmergedatasource of .close, but I could not get this to close the database. i'm thinking in order to do that, i need to merge the data another way besides .opendatasource.

Thanks

Mail Merge Using Vb6, Ms Access And Ms Word
hi,

i'm having a weird problem with visual basic, access and word. i have a client server database set up with a vb6 program as the front end, ms access on the back end, and a mail merge set up to create reports from the database. my problem is that when i run the mail merge on certain machines, instead of creating an ms word file with the relevent field names and data, for some reason the access database itself opens up. is there any way round this?

thanks.

Class Module Help - SQL Merge From Access
I am using the SQLMerge from ACCESS to run a replication on an SQL Server. I did not put the control on the form, I set all the properties in code in a module, and call it from code behind a button control on the form. I want to use the STATUS event. I found out that I have to set it up in a Class module in order to DIM is WithEvents. I am very unfamiliar with this. I understand I need to put something in a class module but I don't exactly know what. Then do I still have all my code to set the properties in the other module I have it in now? Does one call the other?

Any help would be really appriciated!

Thanks,
Steve

MS Access 2000:Merge To MS Word
The code I have below seems to work fine, except for the fact that when I click on the command button to open the word doc and execute the word merge it opens a whole new copy of my database.

The data source in the mail merge word doc is a query in MS Access.

Can someone give some advice as to how to go about this without having a another copy of my database open to execute the merge. Thanks.
Code Below:

Private Sub Command0_Click()


Dim WRD As Word.Application
Dim DOC As Word.Document
Set WRD = New Word.Application
WRD.Visible = True
Set DOC = WRD.Documents.Open("C:Documents and SettingsJoeDesktopVendor Responsiblity Questionnaire.doc")
DOC.MailMerge.Execute

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox "CAU Trak Can't Locate File You Are Trying To Open.", vbOKOnly
Resume Exit_Command0_Click
End Sub

Merge Of 2 Identical Access Databases
I did a search, but found no answer. My question must be too simple.
How do I merge the contents to 2 Access data bases. Both have the same structure, 1 table, same column structure. Do I need to open A and B and then Get Next of B and Insert into A?
LittlerockZ

Help Needed To Merge 2 Access Tables Into One!!!
Hi everyone, ive got another VB function i need help with..

I have an access database called 'db1'. It has 2 tables, DETAILS (name, age) and ORDERS (order number, amount). It is all linked up to VB with data controls, add, delete,save buttons etc..

On the click of a command button I want to merge details of whats being shown in both tables at that time, effectively creating a MERGERD TABLE called say PURCHASES.

Any ideas?

Cheers

Tom

Mail Merge/Access 2000
Hi everyone... I need to create a mail merge in word 2000 from access 2000 and populate the merge fields with data from the tables... Any ideas???

Thanks for any help in advance

[help!] VB-->Access-->mail-merge To Word
I need to mail out 1000 letters to 1000 people. I'm wanting to put their names and addresses into a form letter. Currently I have a ADO Recordset with the 1000 people.

I know that from Access i can do it, and it opens 1 Word document, and then just makes 1000 pages within that one document. Then, I just print those pages. But, i'd rather do it from VB instead of Access.

Is there a way, from VB, to take the Recordset information and merge it into a Word form-letter multiple times?

Eventually, I will be sending out almost 5000 letters. it's going to get large.

I attempted using the 'Bookmark' within Word to setup FIELDS, but when I go to make 1000 pages within the 1 document, it fills only the 1 page with all the addresses!

Anyone have any ideas?
With many thanks,
Chris.

Using Mail Merge With Access - OLE Object
Does anyone know how to mrege an OLE object from an access feild to word without getting the error Long binary or text value

Thanks

IParadoX

Help With Word/Access Mail Merge In VB6
I need help with mail merge using vb6, msword and access. Getting an error called Cannot Create Active X Control. Any thoughts

VB Code:
Dim dbPath As StringDim wordPath As StringDim msWordApp As New Word.Application CommonDialog1.Filter = "| *.doc"CommonDialog1.ShowOpendbPath = App.Path & "database.mdb"wordPath = CommonDialog1.FileName msWordApp.Visible = TruemsWordApp.Documents.Open wordPath    With msWordApp.ActiveDocument.MailMerge          .MainDocumentType = wdFormLetters          .OpenDataSource _        Name:=dbPath, _        LinkToSource:=False, AddToRecentFiles:=False        End With

MSWORD/MS Access Mail Merge VB6
I am using the code below to open the data source for mailmerge but it keeps giving me "Runtime Error: Could not Open Data Source"

Any thoughts,

Ali


VB Code:
.ActiveDocument.MailMerge.OpenDataSource App.Path & "CustMast.mdb", wdOpenFormatAuto, ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=True, AddToRecentFiles:=True, Revert:=False, Connection:="TABLE Contacts", SQLStatement:="" & strSelect, OpenExclusive:=True

Mail Merge From Access To Word
from a form in Access, i would like a user to be able to click a button which will open a Word document and merge the current record from a table in the database. what module do i write to perform this function?

Mail Merge From Access To Word
Hey,
i ahve the following code in my Access data base, trying to make a word letter from it.
After selecting a record from a combo box and then having the needed fields selected, i would like to push a command button that generates the letter auto.

the code i have so far is as follows:

Option Compare Database


Private Sub ChangeofAgency_Click()

End Sub

Private Sub Combo10_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[FundManagerid] = " & Str(Me![Combo10])
    Me.Bookmark = rs.Bookmark
End Sub


Private Sub Command0_Click()
On Error Resume Next
    Dim objWD As Object
    
    Set objWD = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
        If MsgBox("Create a new document?", vbQuestion + vbYesNo, "Cannot Connect to Word") = vbYes Then
            Set objWD = CreateObject("Word.Application")
            objWD.Documents.Add
            objWD.Visible = True
        End If
    End If
    With objWD.Selection
        .Collapse 0 'Collapse the selection to the end
        .TypeText vbCrLf
        .TypeText vbCrLf
        .TypeText vbCrLf
        .TypeText vbCrLf
        .TypeText vbCrLf
        .TypeText (Address_Title)
        .TypeText vbCrLf
        .TypeText (Address_Line_1)
        .TypeText vbCrLf
        .TypeText (Address_Line_2)
        .TypeText vbCrLf
        .TypeText (Address_Line_3)
        .TypeText vbCrLf
        .TypeText (Address_Line_4)
        .TypeText vbCrLf
        .TypeText (Address_Line_5)
        .TypeText vbCrLf
        .TypeText (POSTCODE)
        .TypeText vbCrLf
        .TypeText vbCrLf
        .TypeText Format(Now(), "Short Date") & vbCrLf
        .TypeText vbCrLf
        'text of letter in here

    End With
End Sub


Any help would be great

cheers
nick

Mail Merge From Access To Word
Using Access 2003 (database format is 2003) and Word 2003, am trying to merge a document from a list box to a table in the current database (table name is MergeSource). It opens the word doc but brings up a dialog box asking me to select a table. I thought I had specified the table in the OpenDataSource statement. What am I doing wrong?

Have looked in the Help file, MS KB and on several web pages, but no luck, until now I Hope.


Code:Dim WordApp As Object
Dim WordDoc As Object
   
      Set WordApp = CreateObject("Word.Application")
      Set WordDoc = WordApp.Documents.Open(strDirPath & Me.lstFiles & ".doc")
      WordApp.Visible = True
      WordDoc.MailMerge.OpenDataSource Name:=CurrentDb.Name, LinkToSource:=True, Connection:="TABLE MergeSource"
   
   With WordDoc.MailMerge
      .Destination = 0 ' 0 = new doc
      .MailAsAttachment = False
      .MailAddressFieldName = ""
      .MailSubject = ""
      .SuppressBlankLines = True
      With .DataSource
         .FirstRecord = 1
      End With
      .Execute Pause:=True
   End With

Thanks in advance - Max



Edited by - cccnv on 8/10/2007 10:40:11 AM

What Is The Best Way I Can Merge Two Tables From Two Different Access Databases?
The reason I'm posting this in the lounge is because it doesn't have to be done in VB. Just any method to merge the two tables, which have identically named columns and no ID(Primary/AutoNumber) columns. Although I'm open to VB solutions (vb6). Also need to append additions only (no duplicates).

Thanks in advance...

Automated Merge To Word From Access
I have an existing Word document I want to merge to from an Access query that has parameter prompts of: Between[Type starting date] And [Type ending Date]
I am using this code below and it does:
1. Bring up the Word Document
2. Gives me an exception error which I am including as graphic

It does not:

1. Prompt me for my input with the Between and And parameter I set in the query
2. Activate the Word merge bar once word is open...its all grayed out

Here is my function:

Code:Function MergeIt()
Dim objWord As Word.Document
   Set objWord = GetObject("A:MergeLetter-PymtDue2.doc", "Word.Document")
   ' Make Word visible.
   objWord.Application.Visible = True
   ' Set the mail merge data source as the Example database.
   objWord.MailMerge.OpenDataSource _
      Name:="C:Documents and SettingsNannetteDesktopExample.mdb", _
      LinkToSource:=True, _
      Connection:="QUERY qryMonthlyBillingMerge", _
      SQLStatement:="SELECT * FROM [qryMonthlyBillingMerge]"
   ' Execute the mail merge.
   objWord.MailMerge.Execute
End Function


When I type: ?MergeIt() in the Intermediate window it does what I said above but that is all...
I did click References on the Tools menu. Add the Word 10 Object Library to the list of available references first, so that's not it...

HELP
The whole idea is I would like a command button on the Main form in Access that will allow the user to click it and the query will open ask for parameter input and then send the results to the existing word document merged.

Thank you,
NMP

"If you can't convince them, confuse them" - Harry S. Truman

Edited by - NMP on 4/8/2004 6:39:55 PM

Any MS Access Mail Merge Experts Around
I am trying to merge data with MS Word, but am getting problems. I only seem to be able to merge a single record. Can anyone help pls as this is quite urgent


Thanks


EDIT by johnminkjan -> moved to VBA board



Edited by - johnminkjan on 6/11/2005 12:39:32 PM

Merge Cells In Access Grid
Hi...

I ask your help for a VBscript problem... I wan to do a merge of cells in a grid component of MS Access...
Someone knows if is it possible?
Thanks
Cristiane

Mail Merge Problem Access-&gt; Word
Ok here is my little problem.
Whenever I'm trying to mail merge a word document
it takes up to 2 minutes before the document is merged.

I've put a flesh next to the line what takes most of the time

I was hoping that someone could tell how to open a
specific Word document much faster.



Code:
Private Sub cmdPubliposter_Click()
On Error GoTo Err_cmdPubliposter_Click
Dim wdApp As Word.Application
Dim intposition As Integer
Dim path_Lettre As String



' On va ouvrir word et lancer le publipostage

path_Lettre = "D:DataDatabasesLettresTypePremièreInstance" & lstLettreType.Value


Set wdApp = CreateObject("word.application")
With wdApp
.Visible = True
.ShowMe

.Documents.Open path_Lettre '← taking to long
.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
.ActiveDocument.MailMerge.Execute
.Documents(path_Lettre).Close (wdDoNotSaveChanges)
End With

'Documents(path_Lettre).Close savechanges:=wdDoNotSaveChanges

Set wdApp = Nothing

Exit_cmdPubliposter_Click:
Exit Sub

Err_cmdPubliposter_Click:
MsgBox Err.Description
Resume Exit_cmdPubliposter_Click

End Sub

Call A Word Mail Merge From Access?
I have a a huge macro that manipulates data automatically for update purposes and I have a word document set up as a mail merge for the data in the spreadsheet.

I would like to open the word document and execute the mail merge (parameters already set in word) such that the merge will run and output the results to a new file. The mail merge template should then close and the user left with focus on the new document (so users can check and print). I would like to do this within my macro in access.

I need to know the VB code as I'm a bit of a VB novice.

Thanks

Why Does Mail Merge Start Another Copy Of Access?
Hi, again, when I call a mail merge from an access module it starts another copy of Access and, even though word is running in minimised state, it also starts another copy of Word, what can i do to just have the mail merge program kick in from the access application running the module and utilise the already open version of word, rather than start another, all help in this would be greatly appreciated :-)

Access Mail Merge To Word Problem..
Hi,

I have set up a mail merge to word using some vba code in a form in access 2003 and a MS word 2003 template. The following code is activated when a command button is pressed in a form in access:


Code:
Private Sub Cmdmakeletter_Click()

Dim objWord As Word.Document
Set objWord = GetObject("C:Documents and SettingsjoeMy Documentsharley street different wayMailMerge Template.dot", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="C:Documents and SettingsjoeMy Documentsharley street different wayHarley Street Database.mdb", _
LinkToSource:=True, _
Connection:="QUERY Personal Information Query", _
SQLStatement:="SELECT * FROM [Personal Information Query]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Sub

The problem that I am having is a very trivial one, but none the less very annoying... When the mail merge is preformed and word opens, in the address block not all the fields I want are shown...It stops cuts off at address line 1 in any/every letter...I have tried setting up the matching in the address block options, but when ever I run the code the settings are overwrited, i.e. the fields I matched manually become unmatched again. I tried this mail merge directly using word instead of the code, and it worked perfectly...so I'm guessing its the code, but I have no Idea what to do...

Any help greatly appreciated.

Thanks

Prevent Access From Opening Upon Mail Merge
Hi,

I am not going to overburden you with code from the whole sub, but here's where I open the data source to create the mail merge doc in Word:


Code:
With objDoc
.MailMerge.OpenDataSource Name:=App.Path & "
e2.mdb", _
LinkToSource:=True, Connection:="TABLE Merge", _
SQLStatement:="select * from [Merge]"

end with


This works fine but, when this happens, Access opens (the actual program opens). This concerns me for a couple of reasons. One, I don't want users messing with the database. Two, I don't know what would happen if the user didn't have Access and only the runtime Jet engine, maybe an error would result when it tried to open Access.

It seems to me that Word should be able to grab the data without actually opening the Access program.

Thanks -

Nick

Word And Access 2000 Mail Merge
I have an Access 2000 database and have written a series of reports using mail merge, picking up a Word template for the merge. Within the template I have a particular mergefield which should display a text field in blue text if another boolean field is True, otherwise display as normal black text. can anyone advise how best to do this?   

Data Merge From Excel To Access Using Vb Coding
Hi,
    i have some data in the excel. I want to merge the data
from excel sheet to the access using vb code. I would be thankful if anyone solve this issue

Data Merge From Excel To Access Using Vb Coding
Hi,
    i have some data in the excel. I want to merge the data
from excel sheet to the access using vb code. I would be thankful if anyone solve this issue



Edited by - satishkumar on 3/26/2003 10:07:19 PM

Mail Merge From Access Into A Word Document Using VB
Is it possible to execute a mail merge from an Access database on the web? I have an Access database online and I want to be able to merge database records into a Word document from a web browser.

I can't seem to find an answer.
Thanks!

Cheers!
MADMAX, Houston, TX

Automatic Access Merge Qry To Existing Word Doc
I would like a command button to perform this action for me ----- when i click on a specific query, then click on the office links icon and tell it to merge and link to existing document in word...is there a way to write a macro or clip of vba or an sql string to accomplish this task.

I would like the command button on my main form, so a user who does not have access to the design view of my database objects can just click this command button, it merges the specified query to existing word document.

I have been reading the methods written here so far, and none I see answer that in particular.
Thank you,
NMP


"If you can't convince them, confuse them" - Harry S. Truman

Need Help Getting Started - Mail Merge From Access To Word
I am trying to create a mail merge with VB. I have a mail-merge template and an access database. But I need help understanding the basics of how to go about this. Which is the recommended way to open my document template in word? How do I merge my data to the set fields?

If someone could PLEASE give me a brief step-by-step guide on how to go about this, with maybe a couple of key lines of code, it would be greatly appreciated. I do not want the whole code written out for me, otherwise, I'm learning NOTHING!

JorgeM

Problem With Mail Merge In Word From MS Access
I have an application designed in Access 97 that does a mail merge via MS Word. This has been working to 5 years. Recently the client got a new computer running XP and MS word 2003.

Now the application gives an error message on the merge 'Unable to connect to Datasource'

the code is bog standard (see below) and has been working with older versions of Word for ages.

Does anyone have any clues as to why this has now failed?

fyi code...
Code:
    ' get an instance of word
    Err.Number = 0
    On Error Resume Next
    Set appWd = GetObject(, "Word.Application")
    theError = Err.Number
    On Error GoTo MergeWordLetterError
    
    If theError = 429 Then
        Set appWd = CreateObject("Word.Application")
    ElseIf theError <> 0 Then
        Err.Raise MAILMERGEERROR, , "Error opening Word"
    End If

    On Error GoTo MergeWordLetterError
    
    '
    ' if word is not visible make it so and store the state
    If appWd.Visible Then
        boolVisible = True
    Else
        boolVisible = False
        'appWd.Visible = True
    End If
    
     ' make the state minimised
    appWd.WindowState = wdWindowStateMinimize
   ' open the document
   
    appWd.Activate
    Set d = appWd.Documents.Open(strDocFileName)

    ' get a merge object
    Set mmerge = ActiveDocument.MailMerge

    ' connect to the ODBC DSN and merge
    With mmerge
        strConnect = "DSN=" & strDSN & ";DBQ=" & strDatabaseName & "; FIL=RedISAM;"
        .OpenDataSource Name:=gblstrDbName, Connection:=strConnect, SQLStatement:="SELECT * from " & strTableName
        .Destination = wdSendToNewDocument
        .Execute
    End With
    
    ' print the merge and close both the new merged doc and the original letter file
    ActiveDocument.PrintOut
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

Regards

Ray

 

Edited by - Geof on 12/22/2006 5:33:12 PM

Access Datasource With VB Controlled Mail-merge
I’m trying to create a Word merge document with VB using Access as the data source. However, when setting up to merge, I can’t get Word to correctly connect to Access. I’m using the “OpenDataSource” documentation from the VB help that comes with Office XP. When I try to use their examples, they don’t seem to work:

Using the first Access example, I get a dialog asking me which table or query I want to select, irregardless of the value of the “Connection” parameter. After I select the table it works fine, but I need something that doesn’t require manually choosing the table.

Using the ODBC example I get error 5922, “Word was unable to open the data source”

When I try to use “DataSource.ConnectString” on a merge connection made from inside Word so that I can see an example of a correct connection string I get error 9121, “Buffer for return string is too small”. I get this error regardless of whether I use MsgBox, print to string, assign to a variable (fixed length or otherwise). I can’t even use Len on this property to try to determine the length.

Help on any or all of these issues would be greatly appreciated.

Thanks in advance -- Mike

Use Ms Access Query As A Data Source For Mail Merge
Hi All,

I have written a program in VB 6.0 which uses mail merge feature of MS word. As a data source i am using MS Access query. It works fine with MS word 2000. But when I try to run the app on the machine which has MS word 2003(the reference used for word app is MSWORD10.OLB in VB project) or MS word 2002, it gives me a "Confirm data source" dialog box every time before the merging starts. Is there any way i could avoid it programmatically? Or by changing any settings in MS word?

Awaiting help!!!!!!!!!!!!!!!!!!!!!


Thank you

Reena

(beginner) Merge Data From Access Into Word Document
Hi,

I´m trying to merge data from an access query into a word document. I think itsn´t a difficult thing, but i´m not an expert :-)
Basicaly is the same action as going to tools -> office -> merge with word when que query is selected.

Ah, another thing : I´m using a form and I want to view how many registries have my query . How do I make that ?

tks

Create Access Table From Merge Fields On Word Document
I have developed an application which automatically creates documents by cutting and pasting from a 'master document'. In this document merge fields have been inserted (from an access table called mergefields). I now need to force the user to add data into an access table which contains fields of all merge fields on a particular document.
I am new to this game and this one has got me totally stuck. I would be grateful for any suggestions or snipppets.

Cheers Graeme

Automate Word To Perform A Mail Merge With Access Data
Im a university student and we have been given the following assignment:-

4.    Write a VB program that will allow the user to perform the following processing: -
a)    Select the advertisement to be sent.(The advertisemtns are different word documents.) You may have more than one advertisement.
b)    Select the people to be emailed from the database. You may, for example, want to send your emails to people living in Cardiff or only to females. Add any additional fields of data to the database that you want to use as selection criteria.
c)    Automatically send the advertisement as an email to each of the selected recipients. The user should be prompted to enter a subject for the email prior to sending.

Now all we got given was a microsoft help file and the lecture says she will not help us more. So has any1 got any ideas?

How To Add Merge Fields In Merge Mail During Run-time?
This is about automating merge mail in a word file. The data source is an Excel file. What I want to do is to add the merge fields into the word file dynamically, which means through coding using VBA, not by editing the word file. Can someone tell me the solution? Your answer will be highly appreciated.

Jason

Mail Merge VB Access To Word To Print Multiple Records Via Button
Hey guys.. I'm hoping someone can help me.. I've tried heaps of versions of code that are on the net for mail merges and this is the only one I could get working but I need it to print multiple records not just one by altering the code below.. I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date into txtDate on frmDate and the clicks "View Queried Privacy Records" Once they click this it opens the query form frmPrivacy which then has a command button cmdMailmerge to perform the mail merge and print the records that result from that query. (I would prefer to perform the query and mail merge/print without having to go frmPrivacy)

The command button has the following code:


Private Sub cmdMailmerge_Click()

On Error GoTo MergeButton_Err


'Start Microsoft Word
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")

With objWord
'Make the application visible.
.Visible = True

'Open the document.
.Documents.Open ("H:privacymerge.dot")

'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("Title").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![Title]))
.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![FirstName]))
.ActiveDocument.Bookmarks("LastName").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![LastName]))
.ActiveDocument.Bookmarks("Address1").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![Address1]))
.ActiveDocument.Bookmarks("Address2").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![Address2]))
.ActiveDocument.Bookmarks("State").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![State]))
.ActiveDocument.Bookmarks("PostCode").Select
.Selection.Text = (CStr(Forms![frmPrivacy]![Postcode]))

End With


'Print the document in the foreground so Microsoft Word will not close
'until the document finishes printing.
objWord.ActiveDocument.PrintOut
Do While objWord.BackgroundPrintingStatus > 0
Loop

'Close the document without saving changes.
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

'Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = CreateObject("Word.Application")

Exit Sub

MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next

End If

Exit Sub

End Sub

The above code only mail merges and prints the record that the form is currently on, so one record at a time. I need the mail merge to print all records when the query is run. I was thinking of doing a loop with the number of records so it prints all records but have no idea of how to go about it. Any ideas or suggestions?

Copyright © 2005-08 www.BigResource.com, All rights reserved