M
muyBN
In the following code (brackets [] replace actual path name, etc.), what is
the syntax for assigning the value of the database field to a variable?
And a few more questions:
What would be the equivalent code for doing the same but using a recordset
just to get the data field value then assign it to a variable? In other
words, this would just retrieve the field's value and not make the document
into a merge document, correct?
If I didn't want to use the .odc shown below, what would be the correct
syntax to just reference an Access database named DB.mdb? (I'm asking because
I recorded this from a macro; and I'd like to know all the options so I can
better understand the syntax and principles behind the code.)
ActiveDocument.MailMerge.OpenDataSource Name:="[path]\[datasource].odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, Connection:= _
"Provider=MSDASQL.1;Persist Security Info=False;User ID=b;Extended
Properties=""DBQ=[path]\[database].mdb;DefaultDir=[path];" & _
"Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS
Access;FILEDSN=[path]\[DSN].dsn;MaxBufferSize=2048;MaxScanRows=8;PageTi" _
, SQLStatement:="SELECT [field] FROM `[query]`", SQLStatement1:="",
SubType:=wdMergeSubTypeOther
[variable]=???
the syntax for assigning the value of the database field to a variable?
And a few more questions:
What would be the equivalent code for doing the same but using a recordset
just to get the data field value then assign it to a variable? In other
words, this would just retrieve the field's value and not make the document
into a merge document, correct?
If I didn't want to use the .odc shown below, what would be the correct
syntax to just reference an Access database named DB.mdb? (I'm asking because
I recorded this from a macro; and I'd like to know all the options so I can
better understand the syntax and principles behind the code.)
ActiveDocument.MailMerge.OpenDataSource Name:="[path]\[datasource].odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, Connection:= _
"Provider=MSDASQL.1;Persist Security Info=False;User ID=b;Extended
Properties=""DBQ=[path]\[database].mdb;DefaultDir=[path];" & _
"Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS
Access;FILEDSN=[path]\[DSN].dsn;MaxBufferSize=2048;MaxScanRows=8;PageTi" _
, SQLStatement:="SELECT [field] FROM `[query]`", SQLStatement1:="",
SubType:=wdMergeSubTypeOther
[variable]=???