Need VBA to open linked table

  • Thread starter Thread starter Scott A
  • Start date Start date
S

Scott A

I'm using a public function called acbGetCounter to
extract a value from a table and increment a key field for
my database.

It was working just dandy before I split my database, but
now that I've split out the FE from the BE, I can't use
the OpenRecordset anymore and need to change it to
OpenDatabase.

From the references I've found for this method, I need to
declare the dbname (including the path), exclsive (true),
read-only (true), and source ("").

The only part of the statement I'm not sure about is the
dbname: I don't know what to enter for the path! (you all
can laugh as much as you like)

The 'Cookbook' I have is telling me to use another
function call, acbGetLinkPath to get the path, but that
would mean having a function call that calls another
function? It's really confusing.

Anyhow, I'll tack on the relevant portion of the module
for reference. Thanks in advance to anyone willing to
offer assistance.

Module basFlexAutoNum (fragment):

Set rst = db.OpenRecordset("tblFlexAutoNum", _
dbOpenTable, dbDenyWrite + dbDenyRead)
If Err = 0 Then
intLocked = True
 
You can parse the path to the back end from the Connect property of one of
your linked tables, e.g.:
dbEngine(0)(0).TableDefs("MyLinkedTable").Connect

However, it might be easier to use DMax(). If the field is named MyID, you
want:
Nz(DMax("MyID", "MyTable"), 0) + 1
 
Hi

Instead of

Set rst = db.OpenRecordset("tblFlexAutoNum", _
dbOpenTable, dbDenyWrite + dbDenyRead)

replace dbOpenTable with dbOpenDynaset

Revised open statement

Set rst = db.OpenRecordset("tblFlexAutoNum", _
dbOpenDynaset, dbDenyWrite + dbDenyRead)


Regards

Peter
 
Back
Top