User-Defined Type Not Defined

biggcc

Registered User.
Local time
Today, 08:59
Joined
Aug 1, 2005
Messages
56
What does it mean when I get a compile error "User-Defined Type Not Defined" error. Here is my code but it looks like it sticking on the Dims.

I am a novice so please don't be to hard on me - thanks.

Private Sub Command4_Click()
'Preview Report

Dim db As Database
Dim Q As QueryDef
Dim sql As String

On Error GoTo Command4_Click_Error

If IsNull("Me.txtCriteria1") Or Me.txtCriteria1 = "" Then
Exit Sub
Else

Set db = CurrentDb("EmpCompDatabase")
Set Q = db.QueryDefs("zzztest")
Q.sql = "SELECT [zzzTest].[LastName], [zzzTest].[FirstName], [zzzTest].[Expr1] FROM zzzTest; WHERE (((zzztest.lastname) In (" & Me.txtCriteria1 & ")));"
Q.Close

DoCmd.OpenReport "zzztest", acPreview
End If

On Error GoTo 0
Exit Sub

Command4_Click_Error:
If Err.Number = 2501 Then
Exit Sub
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command4_Click of VBA Document Form_Multi-Select Listbox Example"
End If
End Sub
 
I think you probably need to set a reference to the DAO Library. While viewing any code page (or after Alt F11) go to Tools>References and scroll down to
Microsoft DAO 3.6 Object Library and put a check in the box on that line. OK back to the code page and Debug>Compile. If you are not using ADODB then you should uncheck the reference to
Microsoft ActiveX Data Objects 2.x Library and compile again to make sure there are no errors.
 

Users who are viewing this thread

Back
Top Bottom