Database Object Declaration

M

Michael R

I have the following code in a form's OnLoad:

Dim someData As Database

Dim allTransactions As Recordset
Dim allChecks As Recordset
Dim checkCriteria, paymentCriteria As String

It gives me this error:

"Compile Error

User-defined type not defined"

It highlights the "Dim someData As Database" line of code.

Is there any reason why Access wouldn't have a Database
type?
 
M

Michael R

How would I change the code to work then? I'm not sure
what you mean by the fact I must reference DAO 3.51 or
3.6.
 
R

Rob Waibel

under TOOLS/References you can declare (Check mark) then
Microsoft DAO 3.6 Object Library.

One you have done that, change your declarations to the
following:

Dim someData As DAO.Database
Dim allTransactions As DAO.Recordset
Dim allChecks As DAO.Recordset

This should fix your issue.
 
B

Bruce M. Thompson

I'm not sure
what you mean by the fact I must reference DAO 3.51 or
3.6.

See:

ACC2000: By Default, New Access Databases Do Not Include Reference to Microsoft
DAO Object Library
http://support.microsoft.com/default.aspx?scid=kb;en-us;225962

References That You Must Set When You Work with Microsoft Access
http://support.microsoft.com/default.aspx?scid=kb;en-us;197110

Then, disambiguate your data object variable types by explicitly typing them as
DAO objects:

Dim someData As DAO.Database 'Presently not needed, but later ...?
Dim allTransactions As DAO.Recordset
Dim allChecks As DAO.Recordset

'You must explicitly type each variable, or they will dim as Variant
Dim checkCriteria, paymentCriteria As String
Dim checkCriteria As String, paymentCriteria As String
 

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

Compile Error 1
Not recognizing specification 4
ms ACCESS 97 error 2645 1
Database not a recognized data type 3
User Defined 3
Update form record 5
ODBC connnection 1
Serializing/deserializing a List<> object 1

Top