Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / June 2005



Tip: Looking for answers? Try searching our database.

Dim db As Database doesn't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Howell - 28 Jun 2005 19:31 GMT
I am now working in Access 2002 and am trying to define a recordset in my
current database.  In Acc 2000 I used to be able to define an object as type
"database", but Access 2002 does not recognize the type.  Do I have something
turned off or is there a new way to open a recordset?
Thanks,
Bill
Douglas J. Steele - 28 Jun 2005 23:40 GMT
Database is a DAO object. By default, Access 2002 uses ADO (Access 2000 does
too, so you must have corrected it there and forgotten)

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am now working in Access 2002 and am trying to define a recordset in my
> current database.  In Acc 2000 I used to be able to define an object as
[quoted text clipped - 4 lines]
> Thanks,
> Bill
Bill Howell - 29 Jun 2005 14:22 GMT
Doug,
Thanks for the reply.  My memory is a bit rusty and I may have been using
Access98.  My current problems stemmed from the help file of ACC2002, which
gives only the Database/Recordset examples that were failing for me.  Is ADO
a better way to go for small internal recordsets in VBA?  If so, where can I
find code samples?  
Bill

> Database is a DAO object. By default, Access 2002 uses ADO (Access 2000 does
> too, so you must have corrected it there and forgotten)
[quoted text clipped - 23 lines]
> > Thanks,
> > Bill
Bill Howell - 29 Jun 2005 14:57 GMT
Doug,
I followed your steps and the Database type is now recognized but I get a
"type mismatch" error on the following code**:
   Dim thisDB As Database
   Dim rsCtl As Recordset
   Set thisDB = CurrentDb
   Set rsCtl = thisDB.OpenRecordset("qryControlDate")  **
I don't remember DAO being this fussy.  :-)
Thanks again for your help.
Bill

> Database is a DAO object. By default, Access 2002 uses ADO (Access 2000 does
> too, so you must have corrected it there and forgotten)
[quoted text clipped - 23 lines]
> > Thanks,
> > Bill
Paul Clement - 29 Jun 2005 16:12 GMT
¤ Doug,
¤ I followed your steps and the Database type is now recognized but I get a
¤ "type mismatch" error on the following code**:
¤     Dim thisDB As Database
¤     Dim rsCtl As Recordset
¤     Set thisDB = CurrentDb
¤     Set rsCtl = thisDB.OpenRecordset("qryControlDate")  **
¤ I don't remember DAO being this fussy.  :-)
¤ Thanks again for your help.
¤ Bill
¤

To avoid confusion with ADO (which also has a Recordset object), fully qualify the database object
types:

Dim thisDB As DAO.Database
Dim rsCtl As DAO.Recordset

Paul
~~~~
Microsoft MVP (Visual Basic)
Bill Howell - 29 Jun 2005 19:41 GMT
Thanks Paul,
That fixed it and it is running fine now.   All I need to do now is figure
out how to copy a table (for backup) using VBA.  But I'll do my homework
first before yelling help here.  By the way, I cannot find any MS Access
specific discussion groups here.  Others have suggested a newsgroup but my
company blocks access to all newsgroups.  I only have access to
support.microsoft.com.
Regards,
Bill

> ¤ Doug,
> ¤ I followed your steps and the Database type is now recognized but I get a
[quoted text clipped - 17 lines]
> ~~~~
> Microsoft MVP (Visual Basic)
Paul Clement - 29 Jun 2005 20:11 GMT
¤ Thanks Paul,
¤ That fixed it and it is running fine now.   All I need to do now is figure
¤ out how to copy a table (for backup) using VBA.  But I'll do my homework
¤ first before yelling help here.  By the way, I cannot find any MS Access
¤ specific discussion groups here.  Others have suggested a newsgroup but my
¤ company blocks access to all newsgroups.  I only have access to
¤ support.microsoft.com.
¤ Regards,
¤ Bill
¤

All the Microsoft Access NNTP newsgroups start with microsoft.public.access.

You could also try the web based interface for the newsgroups:

http://msdn.microsoft.com/newsgroups/topic.aspx?url=/msdn-files/028/201/016/topic.xml

Paul
~~~~
Microsoft MVP (Visual Basic)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.