Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easy Form Filter question

Status
Not open for further replies.

mustangcoupe

Technical User
Feb 26, 2003
221
US
Ok friends... This one is probaly easy but it is too late and the Patriots are playing and I cant concentrate!

filtertype is a combo box bound to a table with combo box caption, field name, sql string for filterby rowsource

filterby is a combo box with diffrent 2 columns( 1 ID number, 2 description)
filterby2 is a plain old text box

using the first half of the if (filterby is > then 0) then I get an enter parimiter value for the filterd field... (it isnt using the filterby control)



Code:
Private Sub Filterform_Click()
Dim strErrNum As String
Dim strErrDesc As String

On Error GoTo Filterform_Click_Error

Dim strFilter As String
If Me.FilterOn = False Then
    strFilter = ""
    If Len(Me.filterby) > 0 Then
    
    strFilter = Me.filtertype.Column(1) & " =" & Me.filterby
    Debug.Print strFilter
    Else
    If Len(Me.filterby2) > 0 Then
    
    strFilter = Me.filtertype.Column(1) & " =" & Me.filterby2
    End If
    End If
    Me.Filter = strFilter
    Me.FilterOn = True
    Me.Filterform.Caption = "Remove Filter"
Else
    strFilter = ""
    Me.Filter = ""
    Me.FilterOn = False
    Me.filtertype = ""
    Me.filterby = ""
    Me.filterby2 = ""
    Me.Filterform.Caption = "Filter Records"
End If
   
   On Error GoTo 0
   Exit Sub

Filterform_Click_Error:
    strErrNum = Err.Number
    strErrDesc = Err.Description
    MsgBox "An error has occured." & Err.Number & " (" & Err.Description & ") An email will be created and sent to Database Administrator."
    Call EmailError(strErrNum, strErrDesc)
    
End Sub

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Debug.Print strFilter
What is displayed in the immediate window ?
What is the exact content of the parameter popup ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
debug.print strfilter = Combo_customer =1100489258

Combo_customer is the control name on the form
that ID number corosponds to customer XYZ

I get an input box titled Enter Parameter Value

Combo_customer
_________________

OK Cancel




--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Instead of the form's control name you have to use the table's field name as it appear in the query you want to filter.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Im not at the computer with this database on it... but I will try and filter on CustomerID instrad of Combo_customer.

--Todd


TechnicalUser pretending to be a programmer(shhh… the boss doesn’t know yet)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top