Full Version: Compile Error: User-defined type not defined.
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
kpark_67
I am trying to open a form based on a query. If the query is EOF open the form on a new record. If the query finds a resulf open the form at that record. Here is my code.

Private Sub
Dim Key
Dim strSQL
Dim db As DAO.Database '(where I get the error)
Dim qdf As DAO.QueryDef

Set db = CurrentDb()
Set qdf = db.QueryDefs(strSQL)

Key = [Forms]![PMSMain]![ListProperties].Value

strSQL = "SELECT AdditionInfo.Key FROM AdditionInfo WHERE(AdditionInfo.Key) = " & Key & ""

Set db = CurrentDb()
Set qdf = db.QueryDefs(strSQL)

qdf.SQL = strSQL

If EOF(qdf) = True Then
DoCmd.OpenForm "FrmOwnInfo", acNormal, , , acFormAdd, acWindowNormal
Forms!FrmOwnInfo!Key = Key
Else
DoCmd.OpenForm "FrmOwnInfo", acNormal, , "Key=" & Key, acFormEdit, acWindowNormal
End If
End Sub
adamsherring
Hi,

Have you added the Microsoft DAO Library Reference?

If not, go to Tools->References and then scroll down to it.
Bob_L
In Access 2002, DAO was not the default - ADO was, so go open the Visual Basic Integrated Development Environment (IDE) Window and go to Tools > References and make sure that Microsoft DAO is checked.
Bob_L
Hmm - seems we posted the same thing at the same time yayhandclap.gif
kpark_67
And you were BOTH right!!! But now I get a Type Mismatch error.

If EOF(qdf) = True Then '(I get the error here)
DoCmd.OpenForm "FrmOwnInfo", acNormal, , , acFormAdd, acWindowNormal
Forms!FrmOwnInfo!Key = Key
Else
DoCmd.OpenForm "FrmOwnInfo", acNormal, , "Key=" & Key, acFormEdit, acWindowNormal
End If
adamsherring
Hi,

EOF isnt a function that you can call and pass a query to..

Are you trying to see if there are any records returned by that query? You can use the recordcoutn property for that, or even skip the whole thing and use a DCount..
kpark_67
DCount worked great!!

Thank you Adam.

Keith
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.