Using ComboBox to Filter Records

DNewman

Registered User.
Local time
Today, 19:44
Joined
Oct 12, 2012
Messages
60
Hi,
I am using Access 2010, Windows 7

I have an unbound form with a combo box and a bound subform on it.

I am using the combo box to get a value to filter (and display) records in the subform.

My code is:

Private Sub cboSessions_AfterUpdate()
On Error GoTo cboSessions_AfterUpdate_Err

Me.SSubform.Visible = True 'subform was initially invisible
Me.SSubform.Form.FilterOn = True
Me.SSubform.Form.Filter = "[LinkID]=" & Me.cboSessions
Me.SSubform.Form.Requery

cboSessions_AfterUpdate_Exit:
Exit Sub
cboSessions_AfterUpdate_Err:
MsgBox Err.Description, vbCritical, "PROGRAM ERROR"
Resume cboSessions_AfterUpdate_Exit

End Sub

The subform is initially invisible to stop it showing all records.

This works fine AFTER the first selection(!) - the first Update of the Combo Box just doesn't filter the subform??

I have tried putting code in the main form's On Load Event - allocating a value to the Combo Box and running cboSessions_AfterUpdate but that does not work either.:banghead:

Any suggestions would be gratefully received.

David Newman
 
Me.SSubform.Form.FilterOn = True
Me.SSubform.Form.Filter = "[LinkID]=" & Me.cboSessions

->

Me.SSubform.Form.Filter = "[LinkID]=" & Me.cboSessions
Me.SSubform.Form.FilterOn = True
 

Users who are viewing this thread

Back
Top Bottom