Results 1 to 2 of 2

Thread: List Box Dims

  1. #1
    Join Date
    Jun 2010

    Unanswered: List Box Dims

    A list box has some variable definitions that I'm trying to write with an old code example I found.....first line errors me:
    Dim db As DAO.Database

    I've tried to remove DAO and I get the same error:
    Complie Error
    User-defined Type Not Defined

    Here's the code:
    Private Sub List0_Click()
    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim varSLMN As Variant
    Dim strSTATUS As String
    Dim strSQL As String

    Set db = CurrentDb()
    Set qdf = db.QueryDefs("AcctbySlmnSelection12811")

    For Each varSLMN In Me!lstSalesmanCode.ItemsSelected
    strCriteria = strCriteria & ",'" & Me!lstSalesmanCode.ItemData(varSLMN) & "'"
    Next varSLMN

    If Len(strCriteria) = 0 Then
    MsgBox "You did not select a salesman from the list", vbExclamation, "No Report to Create"
    Exit Sub
    End If

    strCriteria = Right(strCriteria, Len(strCriteria) - 1)

    strSQL = " SELECT * FROM tblSalesman " & "WHERE tblSalesman.SalesmanCode IN(" & strCriteria & ");"

    DoCmd.OpenQuery "AcctbySlmnSelection12811"

    Set db = Nothing

    End Sub

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    check your references (IIRC Tools | References) and make certain the DAO library is referenced. IIRC from around Access 2000 on the default library was ADO
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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