Error Accessing Database

T

Tony Piperato

Can someone please tell me why I receive the error "Compile Error: User
defined type not defined" on line number 5 below when I try to compile the
following:

Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' Use an InputBox to retrieve user input
' for a custom search using the FindFirst
' and BuildCriteria methods.
Dim dbMyDB As Database (I RECEIVE THE ERROR FOR THIS LINE!)
Dim rsMyRS As Recordset
Dim strInput As String
Dim strCriteria As String
Dim strMsg As String
Dim txtDateStart As Control
Dim txtDateEnd As Control
Dim txtNoneFound As Control
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset _
("ProductUse_QRY", dbOpenDynaset)
strMsg = "Enter the start date"
' Prompt user for input.
strInput = InputBox(strMsg)
' Build a criteria string.
strCriteria = BuildCriteria("DateStart", dbText, strInput)
' Apply the criteria to the FindFirst method.
rsMyRS.FindFirst strCriteria
' Make sure a record was found.
If Not (rsMyRS.NoMatch) Then
txtDateStart = rsMyRS("DateStart")
txtDateEnd = rsMyRS("EndStart")
Debug.Print rsMyRS("DateStart") & " " & _
rsMyRS("DateEnd")
Else
txtNoneFound = "No matching records were found."
Debug.Print "No matching records were found."
End If
rsMyRS.Close
dbMyDB.Close
End Sub


Thanks in advance.

AKP
 
M

Marshall Barton

Tony said:
Can someone please tell me why I receive the error "Compile Error: User
defined type not defined" on line number 5 below when I try to compile the
following:

Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' Use an InputBox to retrieve user input
' for a custom search using the FindFirst
' and BuildCriteria methods.
Dim dbMyDB As Database (I RECEIVE THE ERROR FOR THIS LINE!)


That happens when you have a reference to the ADO library
instead of the DAO library. Open any code module then use
the Tools - References menu to view your references. Make
sure you check the newest Microsoft DAO library (and if you
did not intend to use ADO, uncheck the Microsof ActiveX Data
Objects library)
 

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

Top