Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem happen after setting Security click event (XP Access)

    Private Sub Command1_Click()

    On Error GoTo Err_Command1_Click

    If IsNull(Combo4.Value) Then
    MsgBox "You must select a State Road number", vbOKOnly
    Combo4.SetFocus
    ElseIf Combo5.Value = "" Then
    MsgBox "You must select a Direction of travel", vbOKOnly
    Combo5.SetFocus
    ElseIf Countytxt.Value = "" Then
    MsgBox "You must select at least 1 County", vbOKOnly
    Countytxt.SetFocus
    Else

    Dim ctl As Control
    Dim strSQL As String
    Dim strWhere As String
    Dim qdfTemp As QueryDef


    DoCmd.DeleteObject acQuery, "qryTemp"

    strWhere = "Where "

    For Each ctl In Me.Controls
    If ctl.ControlType = acCheckBox Then
    If ctl.Value Then 'Get the true ones
    strWhere = strWhere & "tblStructures.ConstCounty = " & CInt(ctl.Name) _
    & " Or "
    End If
    End If
    Next ctl

    'Strip the last " OR "

    strWhere = Trim$(Left$(strWhere, Len(strWhere) - 4))

    'Ensure there is at least one condition

    If Len(strWhere) <= 5 Then

    strWhere = vbNullString

    End If

    'Put pieces together - no problem is strWhere = ""

    strSQL = "SELECT tblStructures.* FROM tblStructures " & strWhere

    Set qdfTemp = CurrentDb.CreateQueryDef("qryTemp", strSQL)

    DoCmd.OpenQuery "qryTemp"
    DoCmd.OpenQuery "qryStateRoadReport"
    DoCmd.Close acQuery, "qryTemp", acSaveNo
    DoCmd.Close acQuery, "qryStateRoadReport", acSaveNo
    DoCmd.OpenReport "rptBridgeReportStateRoad", acPreview

    End If

    Exit_Command1_Click:
    Exit Sub

    Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click

    End Sub



    the code stops on
    Dim qdf Temp As QueryDef

    error message is: User defined type not defined

    I can not find anything on QueryDef in help?
    Is there a reference in the module that is needed to be check?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problem happen after setting Security click event (XP Access)

    You're using DAO code, so you have to set a reference to the DAO library. If you also have an ADO reference set, make sure you specify the object model in your declarations--DAO.Database, DAO.Recordset, DAO.QueryDef, etc. The QueryDef object doesn't exist in ADO, which is the default in Access 2000 and Access 2002.
    Charlotte

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem happen after setting Security click event (XP Access)

    Thanks Charlotte,

    I needed DAO 3.6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •