View Single Post
  #9   Report Post  
Posted to microsoft.public.word.mailmerge.fields
mico mico is offline
external usenet poster
 
Posts: 6
Default Database Field SQL Statement

As a final follow up this is what I used:

{ MERGEFIELD "UserID"}

{DATABASE \d "C:\\Temp\\VerizonAirCard.mdb" \s "SELECT [ACCT_NUM], [Phone
Number], [EMIN], [ESN_NUM], [User First Name], [User Last Name], [Location],
[Contact # 1], [Contact #2], [Supervisor Name], [Supervisor Number],
[Multiple Users] FROM [tblAirCard] WHERE [UserID] = '{ MERGEFIELD UserID}' "
\h}

This generates specific data in a table base on the UserID. In my case the
UserID is the persons email address and the data generated in the table was
based on the email address.

As Peter said I didnt need the connect string below:
\c "DSN=MS Access Database;DBQ=
C:\\Temp\\VerizonAirCard.mdb;DefaultDir= C:\\Temp; DriverId=25; FIL=MS
Access; MaxBufferSize=2048; PageTimeout=5; UID=admin;"

I believe the erratic result I was getting was from multiple merge documents
open with multiple data links plus I was not familiar with the F9(Update
Field ) and ALT F9(Toggle Field Codes) function. I think each time I hit F9
a new data link properties panel would appear and I would complete it but the
merge continued to fail. Also being new to the {Database field} function the
€śunable to open data source€ť error made me think there was a problem with the
connect string but this errors appears anytime there is anything wrong with
any part of the Database field statement. IE If you misspell a column name
or if anything is wrong with the SQL statement the €śunable to open data
source€ť error will appear when you hit F9.

I hope this helps and that Peter corrects any misleading information in my
note.

"mico" wrote:

OS: XP Pro SP1, Word 2003 SP2

DATABASE \d "C:\\Temp\\VerizonAirCard.mdb" \c "DSN=MS Access Database;DBQ=
C:\\Temp\\VerizonAirCard.mdb;DefaultDir= C:\\Temp;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;UID=admin; " \s "SELECT * FROM
'tblAirCard' "

Ive been unable to change the select statement above to work properly.
Ive tried to use tic, backslash and tic and backslash to denote the columns
names and Ive tried using the tablename.fieldname, tablename!fieldname and
just the field name by itself and everything generates the generic Word error
unable to open data source. Any advice is appreciated.