Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

currentdb.openrecordset not working 2

Status
Not open for further replies.

emik

MIS
Jul 24, 2006
80
CA
Hi,

I have a previous Access application (front end and back end) and all I do to reference a table is:

Dim test as recordset
Set test = currentdb.openrecordset("Table1")

I don't have any other variables pointing to the database.

Now I've always done it this way and it's always worked but my friend here on another computer always gets a "Type mismatch" error. I made sure he has all the same VBA references as me, but for some reason it still won't work on his PC.

Does anyone know what causes the currentdb to work? I use it because it's short and clean but is it a bad way of doing things?

Thanks.
 
Try:

Dim Test as DAO.Recordset

Ed Metcalfe

Please do not feed the trolls.....
 
Always be explicit about defining objects.
Code:
Dim test as [red]DAO.[/red]recordset
You may have the same references but they may be in a different order in the list of references so you are finding DAO.Recordset first while he is finding ADODB.Recordset.
 
With your syntax you must use DAO. Converting an application from DAO to ADO is non-trivial and you should not mix DAO and ADO in the same application because, since they are not synchronized, serious corruption can result.
 
That depends. My rule is:

DAO - For accessing MS Access (Jet) tables. Because it's faster.
ADODB - Anything else.

I believe MS agree with this.

Ed Metcalfe.

Please do not feed the trolls.....
 
I just started investigating and I realized this is an open debate on which is better. I'm thinking more about future applications and how I should go about developing them.
 
As usual you have all been a tremendous help.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top