Thanks NeoPa. The #2 option works. I added View:=acFormDS in order to open 2nd form as datasheet.
Now I am testing the #1 option. Instead of a command button and a text box, I am planning to place the option #1 codes in the After Update event of a Combo Box for convenient reason. User would click and choose desired item code. After update, the 2nd form opened with two filter criteria.
However, I am stuck with an error message 3464, data type mismatch in criteria expression.
The item code is a text field in the table. Does that require a different VBA code? Your message says assuming item code is a numeric, which make me think the code may need to be different.
Also, is there a instruction somewhere to guide how and the purposes to place quotation mark (“ or ‘) and bracket (() or [])? I am very confused with this. VBA is brand new to me.
Below is the code I have and the debug stopped at the line starting with Call.
Thanks.
-
-
Private Sub cmb_Price_Hist_AfterUpdate()
-
-
-
Dim strFilter As String
-
-
strFilter = "([ordH_cust_no]='" & Me.txt_ordh_cust_no & "') AND " & _
-
"([ordd_stock_no]=" & Me.cmb_Price_Hist & ")"
-
-
Call DoCmd.OpenForm(FormName:="F_Ord_History", View:=acFormDS, WhereCondition:=strFilter)
-
-
End Sub
-