Hi guys,
Thanks for the info. i used it to put a afterupdate event for each of my combo's to try to eliminate the need for the filter button.
I have the following code now attached to my combo boxes. Still got a few problems.
1) When i select criteria from ProjectCode combo, a dialog screen pops up
> Enter Parameter Value - Vendor code
Vendor code is my second combo box
2) Code stops at Me.FilterOn = True is the cboProjectCode_AfterUpdate() macro.
Option Compare Database
Option Explicit
Dim strF As String
Private Sub cboProjectCode_AfterUpdate()
'On Error Resume Next
BuildFilter
' If criteria selected to Filter on
If strF <> "" Or IsNull(strF) Then
' Assign the filter string to build form filter
Me.Filter = strF
' Turn on form filter
Me.FilterOn = True
Else
' Turn off form filter
Me.FilterOn = False
End If
End Sub
Private Sub cboVendor_AfterUpdate()
'On Error Resume Next
BuildFilter
If strF <> "" Or IsNull(strF) Then
Me.Filter = strF
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub
Private Sub BuildFilter()
' Make sure at least one criteria is selected.
If (IsNull(cboProjectCode) Or cboProjectCode = "") And (IsNull(cboVendor) Or cboVendor = "") Then
strF = ""
Else
If IsNull(cboProjectCode) = False And cboProjectCode <> "" Then
strF = "[ProjectCode]='" & cboProjectCode & "'"
Else
strF = "[ProjectCode] LIKE '*' "
End If
If IsNull(cboVendor) = False And cboVendor <> "" Then
strF = "[Vendor]='" & cboVendor & "'"
Else
strF = "[Vendor] LIKE '*' "
End If
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.cboProjectCode = Null
Me.cboVendor = Null
End Sub
Hope you can help.
Thanks tammyl