Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    LA, CA
    Posts
    54

    Question Unanswered: Help with form that runs query Pt 2... electric Boogaloo

    I took care of the "either query by what the value is in the text box or return all records" part (which I asked in previous thread) but now i am having problem with a forced selection:

    The user has option to select the # of local of employees (or another field with the Amount of Gross Sales) and there are categories to chose from:
    1) >= 5 ees
    2) 6-10 ees
    3) etc. etc. etc.

    For some reason, I can't get the "Between 6 and 10" to move from the form to the query... ARGH... please see my code:

    Private Sub Command15_Click()
    On Error GoTo Err_Command15_Click
    Dim stDocName As String
    Dim strParameter As String


    If Me.Combo13 = "" Then
    strParameter = "*"
    Else
    strParameter = Me.Combo13
    End If

    stDocName = "qryMailingList"
    DoCmd.OpenQuery stDocName, acViewNormal, acReadOnly

    Exit_Command15_Click:
    Exit Sub

    Err_Command15_Click:
    MsgBox Err.Description
    Resume Exit_Command15_Click

    End Sub


    Why why WHY won't this work!!!???? My brain hurts

    Rachel

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    personaly i'd use a generated SQL statement

    Code:
    dim SQLstatement as string
    SQLstatement = "Select "
    If Me.Combo13 = "" Then
        SQLstatement = SQLstatement & "* "
    Else
        SQLstatement = SQLstatement & Me.Combo13 & " "
    End If
    SQLstatement = "From your table"
    
    if selected<>null then 
    SQLstatement = "Where "...
    endif
    
    SQLstatement = SQLstatement & ";"
    currentdb.CreateQueryDef("qryGenerated",SQLstatement)
    i wrote this on the fly so it's totally untested
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    we may want to move this thread to this thread instead.
    Me.Geek = True

Posting Permissions

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