Hye,
I'm new to access vba, I'd like to display the record in the subform.
First step I need to choose customer name in the check box.
Second, after the customer name has been chosen/clicked, the system will be automatically go through the record. For example, my customer name is A, so the system will go through the customer A order IDs in the Customer Table. Then, the system will take the customer A's order ID, and the order ID then being compared with the order ID in the Product Table. If the order ID from Product Table is same as the order ID of Customer Table. Then all the record (such as product name, expiry date, quantity) of the product under the same order ID will be displayed in the subform.
Here is my code. I got pending at the comment 'Display the details in subform.
Sub CustomerList_Review()
Dim db As DAO.Database
Dim rsCustLog As DAO.Recordset
Dim rsPrdLog As DAO.Recordset
Dim ordID As String
Set db = CurrentDb
Set rsCustLog = db.OpenRecordset("CustomerLog")
Set rsPrdLog = db.OpenRecordset("ProductLog")
Do Until rsCustLog.EOF
If rsCustLog("CUSTOMER NAME").Value = Forms![Customer Review].cbxCustName Then
ordID = rsCustLog("CUSTOMER NAME").Value
Do Until rsPrdLog.EOF
If rsPrdLog("ORDER ID").Value = ordID Then
'Display the details in the subform
End If
rsPrdLog.MoveNext
End If
rsCustLog.MoveNext
Loop
End Sub
So whenever I click different customer name, the product details will change regarding to the customer name order IDs. If you got more simple code. Let me know.
Thanks for helping.