error during loading dll

H

Helmut Blass

Hello,
I am faced with a strange problem.
I have an Access2003 application with a routine to connect tables in
external mdb's.

Dim tdf as TableDef
Set tdf = CurrentDb.TableDefs

since a few days this command produces an error on _one_ computer
"error during loading dll".
The code worked fine for a long time and still works fine on other
computers.
I tried several methods to fix the problem:

- checked references
- created new mdb and imported all objects
- replaced CurrentDb by a Database variable
- compress/repair
- installation/repair
- deinstalled and re-installed Office
- sfc /scannow

....but of no avail.

any ideas?

Os is Windows 7.

thanx for your help, Helmut
 
D

Douglas J Steele

I don't understand how it could be working on any machine, since it's
incorrect syntax.

You must indicate which table you want, using one of the following
approaches:

Set tdf = CurrentDb.TableDefs(0)
Set tdf = CurrentDb.TableDefs("NameOfTable")

"Helmut Blass" wrote in message

Hello,
I am faced with a strange problem.
I have an Access2003 application with a routine to connect tables in
external mdb's.

Dim tdf as TableDef
Set tdf = CurrentDb.TableDefs

since a few days this command produces an error on _one_ computer
"error during loading dll".
The code worked fine for a long time and still works fine on other
computers.
I tried several methods to fix the problem:

- checked references
- created new mdb and imported all objects
- replaced CurrentDb by a Database variable
- compress/repair
- installation/repair
- deinstalled and re-installed Office
- sfc /scannow

....but of no avail.

any ideas?

Os is Windows 7.

thanx for your help, Helmut
 
H

Helmut Blass

I don't understand how it could be working on any machine, since it's
incorrect syntax.

You must indicate which table you want, using one of the following
approaches:

Set tdf = CurrentDb.TableDefs(0)
Set tdf = CurrentDb.TableDefs("NameOfTable")

Sorry, I copied the wrong code.
The statement, where the error occurs, is

(Dim tdf as TableDef)

For Each tdf In CurrentDb.TableDefs

Helmut
 
D

Douglas J Steele

While I don't know whether it'll solve the problem, you cannot use the
TableDefs collection without instantiating the Database object first:

Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb
For Each tdf In db.TableDefs

"Helmut Blass" wrote in message

I don't understand how it could be working on any machine, since it's
incorrect syntax.

You must indicate which table you want, using one of the following
approaches:

Set tdf = CurrentDb.TableDefs(0)
Set tdf = CurrentDb.TableDefs("NameOfTable")

Sorry, I copied the wrong code.
The statement, where the error occurs, is

(Dim tdf as TableDef)

For Each tdf In CurrentDb.TableDefs

Helmut
 
D

David-W-Fenton

While I don't know whether it'll solve the problem, you cannot use
the TableDefs collection without instantiating the Database object
first:

Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb
For Each tdf In db.TableDefs

This works just fine:

For Each tdf In CurrentDb.TableDefs

....because the For/Each loop maintains the CurrentDB object through
the life of the loop.

What doesn't work is this:

Dim tdf As DAO.TableDef

Set tdf = CurrentDB.TableDefs("MyTable")
Debug.Print tdf.RecordCount

That will give an error, as you say, because the database object
returned by CurrentDB is no longer available. On the other hand,
this would work fine:

Debug.Print CurrentDB.TableDefs("MyTable").RecordCount

Likewise, this doesn't work:

With CurrentDB.TableDefs("MyTable")
Debug.Print .RecordCount
End With

I'm not entirely certain why the For/Each holds the reference open
but the With/End With doesn't, but that's the way it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top