Double combined Search

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TNGgroup

    Double combined Search

    Hi,

    I have a form, on top of that form I made a cbobox with values called
    cboSearch1, but also 2 checkboxes (chkSearch2 & chkSearch3).
    Now I like to put some code behind a Command Button, so that a search in the
    currect recordset i made on 2 of the 3 field (always cboSearch1 &
    ChkSearch1 or ChkSearch2)

    Thx in advance

    TNG


  • Salad

    #2
    Re: Double combined Search

    TNGgroup wrote:
    [color=blue]
    > Hi,
    >
    > I have a form, on top of that form I made a cbobox with values called
    > cboSearch1, but also 2 checkboxes (chkSearch2 & chkSearch3).
    > Now I like to put some code behind a Command Button, so that a search in the
    > currect recordset i made on 2 of the 3 field (always cboSearch1 &
    > ChkSearch1 or ChkSearch2)
    >
    > Thx in advance
    >
    > TNG[/color]

    Create a subroutine in the code. Maybe callit Findit(). You didn't say what
    your were attempting to find. Here is something generic. It will not work,
    it's just a blueprint on how you can do it.

    Private Sub FindIt()
    Dim rst As DAO.Recordset
    Dim strFind As String 'holds the search filter
    set rst = Me.Recordsetclo ne
    strFind = "[YourFieldName] = '" & Me.cboSearch1 & "'" 'cbo value if text
    field has single quotes
    strFind = "[YourFieldName] = " & Me.cboSearch1 'cbo value if numeric
    field has no quotes
    If chkSearch2 then
    strFind = strFind & " And [SecondField] = True"
    else
    strFind = strFind & " And [ThirdFieldField] = True"
    endif

    rst.findfirst strFind
    If not rst.Nomatch then me.bookmark = rst.bookmark
    set rst = Nothing
    End Sub



    Comment

    Working...