I'd suggest having the combo box in an unbound form and within that form put
a subform, in continuous form or datasheet view, based on a query which lists
ALL items, whether available, in stock etc.
For the subform control in the main unbound form set the LinkMasterFields
property to the name of the combo box, and the LinkChildFields property to
the name of the field in the subform's query which contains the values which
correspond with those in the combo box's list, i.e. 'available', 'in stock'
etc.
When you select an item in the combo box the subform should then
automatically show only those rows which match the selection in the combo box.
If you also want to print a report of the items then also create a report
based on the same query as the subform and add a button to the main form with
code along the following lines in its Click event procedure:
Const conMESSAGE = "Please select an item from the list first."
Dim strCriteria As String
Dim ctrl As Control
Set ctrl = Me.YourComboBox
' make sure an item has been selected
' in the combo box
If Not IsNull(ctrl) Then
strCriteria = "Availability = """ & ctrl & """"
' print report filtered to selected availability
DoCmd.OpenReport "YourReport", WhereCondtion:=strCriteria
Else
MsgBox conMESSAGE, vbExclamation, "Invalid Operation"
End If
In the above example Availability would be the name of the field in the
table, so should be changed to its actual name. You'd also need to change
YourComboBox, YourTable and YourReport to their actual names. Remember than
any object names which include spaces or other special characters must be
wrapped in brackets [like this].
If you want to preview a report rather than print it change the relevant
line to:
DoCmd.OpenReport "YourReport", View:= acViewPreview,
WhereCondtion:=strCriteria
You could of course have two buttons, one to print the report and one to
preview it.
Ken Sheridan
Stafford, England
Arlene said:
Please can you help me as I am trying to run a query by clicking in a combi
box drop down. For example in the combi box I have a List Available, In
stock, Awaiting Stock. What I would like to do is when you click on available
in the combi box I could have a report of every thing that is availble and so
on with In Stock Etc.