Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    1

    command button to filter a subform issue -

    Hello,



    I have a form with a subform. I am trying to filter the subform using mulitple text boxes and combos for search criteria. I have a command button to submit the request. In my subs I am using filter and filteron properties and methods.

    The issue is this.

    If I bring up the form intially and select my criteria and then click my search button. It does nothing. If I click it a second time it filters correctly, which is rather annoying. Afterwards the button works like a charm.

    The code is this:

    Dim strStatus As Integer

    If Not Namecbo = "" And Not cbo_status = "" Then

    Me.Filter = "[Station_Name]= '" & Namecbo & "'"
    Me.FilterOn = True

    If cbo_status = "Closed" Then

    strStatus = -1

    Else

    strStatus = 0

    End If


    Form_sub_frm_station_history.Filter = "[Closed]= '" & strStatus & "'"
    Form_sub_frm_station_history.FilterOn = True

    Else
    End If

    If Not Namecbo = "" And cbo_status = "" Then

    Me.Filter = "[Station_Name]= '" & Namecbo & "'"
    Me.FilterOn = True

    Else

    End If

    If Not cbo_status = "" And Namecbo = "" Then



    If cbo_status = "Closed" Then

    strStatus = -1

    Else

    strStatus = 0

    End If

    Form_sub_frm_station_history.Filter = "[Closed]= '" & strStatus & "'"
    Form_sub_frm_station_history.FilterOn = True

    Else
    End If

    Namecbo = ""
    cbo_status = ""

    Any idea how to get it work intially with out having to click the button a second time.

  2. #2
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    2
    Hey countdrako,

    Where is the cmdButton that your using to filter? On the main form or the subform?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Duplicate command button
    By brettg in forum Database Design
    Replies: 1
    Last Post: 08-04-2008, 04:16 AM
  2. Command button code
    By lfolger in forum Forms
    Replies: 3
    Last Post: 03-25-2008, 04:26 PM
  3. Command button for time & date
    By joet5402 in forum Forms
    Replies: 2
    Last Post: 12-20-2007, 02:59 AM
  4. Open a linked subform with a command button
    By flablueeyedblond in forum Forms
    Replies: 0
    Last Post: 11-18-2005, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums