#1   Report Post  
Posted to microsoft.public.word.docmanagement
Ian McKeag[_2_] Ian McKeag[_2_] is offline
external usenet poster
 
Posts: 7
Default Database field code?

I am using the DATABASE field code to insert data from an Access table which
is fine.. However, I am inerting two of these, which opens the DB for both,
leaving two instances of the same DB open.

Is there anyway to only open the database once for both queries or even not
at all?

Many thanks,
Ian McKeag
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Database field code?

Assuming you are trying to stop the Access program from opening (in
effect, the Jet/ACE database always opens) you need a DATABASE field
that opens the database using either ODBC or OLE DB (neither of which
will start Access). You may also have to work a bit to deal with locking
issues if you need two separate connections.

How to do that depends on precisely which versions of Word and Access
you are using, whether or not you are using a database password and/or
workgroup security, and so on, but for example if it's Word/Access 2007
Word might generate an DATABASE field such as

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \c
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data
Source=C:\\mydbs\\mydb.mdb;Mode=Read;Extended Properties=\"\";Jet
OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Engine
Type=6;Jet OLEDBatabase Locking Mode=0;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet
OLEDB:Support Complex Data=False" \s "SELECT * FROM `mytable`" \h }

which (in that case) you could probably shorten by eliminating the
connection string, i.e. by cutting it to

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \s "SELECT * FROM `mytable`" \h }


If you need to select certain fields, make sure you alias your table
name - it shouldn't be necessary syntactically but Word seems to insist:

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \s "SELECT m.a, m.b FROM `mytable`
m" \h }

If that doesn't help, post your Word/Access version and other info.
about exactly what you are trying to connect to, whether you have a
workgroup security file etc., and I'll see what I can do.

You may also find the examples at

http://tips.pjmsn.me.uk/t0004.htm

useful, although that page discusses a specialised use of DATABASE fields.


Peter Jamieson

http://tips.pjmsn.me.uk

Ian McKeag wrote:
I am using the DATABASE field code to insert data from an Access table which
is fine.. However, I am inerting two of these, which opens the DB for both,
leaving two instances of the same DB open.

Is there anyway to only open the database once for both queries or even not
at all?

Many thanks,
Ian McKeag

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Ian McKeag[_2_] Ian McKeag[_2_] is offline
external usenet poster
 
Posts: 7
Default Database field code?

Peter, that is fantastic!!!! Thanks very much, that has helped me out a
lot!!!!

"Peter Jamieson" wrote:

Assuming you are trying to stop the Access program from opening (in
effect, the Jet/ACE database always opens) you need a DATABASE field
that opens the database using either ODBC or OLE DB (neither of which
will start Access). You may also have to work a bit to deal with locking
issues if you need two separate connections.

How to do that depends on precisely which versions of Word and Access
you are using, whether or not you are using a database password and/or
workgroup security, and so on, but for example if it's Word/Access 2007
Word might generate an DATABASE field such as

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \c
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data
Source=C:\\mydbs\\mydb.mdb;Mode=Read;Extended Properties=\"\";Jet
OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Engine
Type=6;Jet OLEDBatabase Locking Mode=0;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet
OLEDB:Support Complex Data=False" \s "SELECT * FROM `mytable`" \h }

which (in that case) you could probably shorten by eliminating the
connection string, i.e. by cutting it to

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \s "SELECT * FROM `mytable`" \h }


If you need to select certain fields, make sure you alias your table
name - it shouldn't be necessary syntactically but Word seems to insist:

{ DATABASE \d "C:\\mydbs\\mydb.mdb" \s "SELECT m.a, m.b FROM `mytable`
m" \h }

If that doesn't help, post your Word/Access version and other info.
about exactly what you are trying to connect to, whether you have a
workgroup security file etc., and I'll see what I can do.

You may also find the examples at

http://tips.pjmsn.me.uk/t0004.htm

useful, although that page discusses a specialised use of DATABASE fields.


Peter Jamieson

http://tips.pjmsn.me.uk

Ian McKeag wrote:
I am using the DATABASE field code to insert data from an Access table which
is fine.. However, I am inerting two of these, which opens the DB for both,
leaving two instances of the same DB open.

Is there anyway to only open the database once for both queries or even not
at all?

Many thanks,
Ian McKeag


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
{DATABASE} Field code for multiple databases Ian McKeag[_2_] Microsoft Word Help 1 April 23rd 09 09:09 AM
database field - merge single field from excel list Big Bad Bev Microsoft Word Help 1 June 7th 08 10:34 PM
Form Letter Mail Merge using field code: {Database} jyan Mailmerge 8 December 19th 05 09:18 PM
Word 2003 Field code within a field code Cheryl Mailmerge 2 November 25th 05 08:31 AM
User-defined table format using Database field code Papy2000 Mailmerge 1 December 19th 04 10:38 AM


All times are GMT +1. The time now is 05:58 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"