Filter a subform from a combobox selection

  • Thread starter Thread starter Jasun74
  • Start date Start date
J

Jasun74

This is probably very simple but it has me taxed and I cant find the answer
after trawling through the forum....

I have a form with a combo box called "combo8".
It is based on the table "Trolley" using only the "serial No" field from
that one.

I want to be able to either double click or press enter after selection on
the "combo8" combobox and then have it open the "trolley" form with it
filtered to show only the one matching page based on "serial No"
Thanks.
 
If the serial No column is a number data type then the code for the control's
DblClick event procedure would be :

Const conFORM = "frmTrolley"
Dim strCriteria As String
Dim ctrl as Control

Set ctrl = Me.combo8

If Not IsNull(ctrl) Then
strCriteria = "[serial No] = " & ctrl
DoCmd.OpenForm conForm, _
WhereCondition:=strCriteria
End If

where frmTrolley is the name of the form to be opened. If serial No is text
data type amend the code with:

strCriteria = "[serial No] = """ & ctrl & """"

If you want the code to execute immediately upon selection use the control's
AfterUpdate event procedure.

Ken Sheridan
Stafford, England
 
Back
Top