Help is needed urgently

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a continuous form with a combo box in the form
header to filter the records.
The combo box row source is based on a union query (in
order to add "*"(all) to the list of values).
The underlying query for the table uses the following
criteria:

Like [Forms]![MyContinuousForm]![MyComboBox]

The combo box has the following values:

*
10
11
1111
1145

I have the following problem:
When I select "10" or "1111" or "1145" in the combo box,
everything is OK - the form shows only required records.
But when I select "11" the form doesn't show any records,
although the records exist in the underlying table.
If I select "*" (all records) the form shows all the
records except records with "11".
What is wrong?
 
Don't worry about the asterisk.
Set the source for your ComboBox to pull all the values
you need from the source query/table for your form (SELECT
DISTINCT tblSource.Value from tblSource) and in the
AfterUpdate event for the ComboBox just apply a filter:

Private Sub cboMyComboBox_AfterUpdate()

' if a value has not been selected for filter
' criteria, do not filter the form
If IsNull([cboMyComboBox]) Or [cboMyCpomboBox]="" Then
Exit Sub
' otherwise filter the form for the selected value
Else
Dim strFilter As String
strFilter = "[Field] = " & [MyComboBox]
DoCmd.ApplyFilter , strFilter
End Sub

Hope this helps!

Howard Brody
 
Back
Top