Ask Experts Questions for FREE Help !
Ask
    barrbe's Avatar
    barrbe Posts: 3, Reputation: 1
    New Member
     
    #1

    Aug 10, 2011, 11:04 AM
    Redefining a search using option group
    This is a continuation of a couple threads from AllExperts because the followups were limited there...
    pt1: http://www.allexperts.com/user.cgi?m=6&catID=1440&expID=47239&qID=4846172
    pt2: http://www.allexperts.com/user.cgi?m=6&catID=1440&expID=47239&qID=4846439

    My original question was: I have a form that basically filters the table based on the information input into unbound text boxes. I would like to refine this filtered table by using an option group that filters based on the status of the standard.
    I've now got a code doesn't give me an error message but isn't filtering the results either. I've been told that I need to create a look up table that has a description for each status, but a number that is actually stored. I'm not sure how to set up this look up table and what needs to be where in it.

    The code for my form is:

    Code:
    Private Sub cmdFilter_Click()
        'Purpose: Allow one to search db by either name, lot number, or gc/ms number. This also allows one to search by partials of any of these fields.
        Dim strWhere As String
        
        If Not IsNull(Me.txtFilterStandardName) Then
            strWhere = strWhere & "([StandardName] Like ""*" & Me.txtFilterStandardName & "*"")"
        End If
        
        If Not IsNull(Me.txtFilterLotNumber) Then
            strWhere = strWhere & "([LotNumber] Like ""*" & Me.txtFilterLotNumber & "*"")"
        End If
        
        If Not IsNull(Me.txtFilterGCMSNumber) Then
            strWhere = strWhere & "([GCMSNumber] Like ""*" & Me.txtFilterGCMSNumber & "*"")"
        End If
        
        
        'Apply Filter
        Me.Filter = strWhere
        Me.FilterOn = True
    End Sub
    
    
    Private Sub cmdReset_Click()
        'Purpose:   Clear all the search boxes in the Form Header, and show all records again.
        Dim ctl As Control
        
        'Clear all the controls in the Form Header section.
        For Each ctl In Me.Section(acHeader).Controls
            Select Case ctl.ControlType
            Case acTextBox
                ctl.Value = Null
            Case acOptionGroup
                ctl.Value = Null
            End Select
        Next
        
        'Remove the form's filter.
        Me.FilterOn = False
        Me.Frame70 = False
    End Sub
    Private Sub Frame70_AfterUpdate()
            
        'Purpose: to be able to refine the search results based on the status of the standard.
        DoCmd.ApplyFilter "[Status] = " & Me.Frame70 & " AND [StandardName] = '*" & Me.txtFilterStandardName & "*'"
     
    End Sub
    Any help is greatly appreciated.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Aug 10, 2011, 12:22 PM

    Ok, lets start with what level of statuses you have. What is now stored in the Status field in the table you are filtering? Also what data type is the Status field?
    barrbe's Avatar
    barrbe Posts: 3, Reputation: 1
    New Member
     
    #3

    Aug 10, 2011, 12:56 PM
    The status field currently has "Active" , "Inactive" , and "Archived" as the options based on if the chemical is opened, not opened or old.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Aug 10, 2011, 04:02 PM

    Ok, but what is stored in the field? What datatype is it?
    barrbe's Avatar
    barrbe Posts: 3, Reputation: 1
    New Member
     
    #5

    Aug 10, 2011, 05:00 PM
    It is a text field with a value box
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #6

    Aug 10, 2011, 05:34 PM

    OK, that's why it hasn't been working. You had said that the value returned by the option group corresponded to what is stored, but its not.

    So you have three choices. You can convert the value stored in the option group to text, you can use a combobox instead of an option group. Or you can can store a numerical code rather than the text. If you use the 1st or 3rd choices then you should create a lookup table for status. Like so:

    tluStatus
    StatusD (PK Autonumber)
    Status

    So, in the 1st option you would convert the number selected in the option group to the text. Then use the text in your Where clause. In the third option you store number and then use joins to pull the text. In the 2nd option, you use a combo to pick the text.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Google Search - question about Date option [ 1 Answers ]

I want to always have Google Search find results within the last year. Without having to go to Advanced, is there a way to have it do this all the time?

Option Group [ 1 Answers ]

Ok.. see if I can ask this correctly... I have an option group with 8 values. Each value has corresponding text I need in one report. To do this the option group is unbound. I used VBA code with a case statement to update a new text box bound to the option group and a case statement for the form...

Search option [ 1 Answers ]

Hey, does anyone know how to add or program a searchbox so that someone can search within my pages. I'm building a page for TV shows, and I want people to be able to search it up instead of going through all the show names...


View more questions Search