Hi,
In a Nutshell, I have two tables one with Orders and one with Product Details. The Orders table has multiple Product ID's (ProductID1, ProductID2, etc..) fields which accommodates more than one item on an order.
I have a form (Orders table is the record source) where order details are filled in as well as a number of combo boxes which lookup Product ID's in the Product details table. There are print buttons next to each combo box, as i will need to print paperwork for each product
Where I run into problems is the query, it works if i put values in manually but i would like to automate it. I have a query which looks like this:
Code:
SELECT Orders.ID, Orders.Company, Products.Description
FROM Orders, Products
WHERE Products.ProductID = Orders.ProductID1
AND Orders.ID = 1
Firstly I would like the the "Orders.ProductID1" to be update depending on which print button you press e.g. you press the print button next to the third combo and the query criteria changes to Orders.ProductID3 box.
Then I would like the "1" (Orders.ID = 1), to change to the current record of the form.
The VBA behind the Print button currently looks like this, I'm not sure how I would go about automating the changes above, or whether the print button is the best place to do it?
Code:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "Title Page", acViewNormal, , strWhere
DoCmd.OpenReport "Checklist", acViewNormal, , strWhere
DoCmd.OpenReport "Information Index", acViewNormal, , strWhere
DoCmd.OpenReport "Sterilisation Sheet", acViewNormal, , strWhere
DoCmd.OpenReport "Label Request", acViewNormal, , strWhere
DoCmd.OpenReport "Label Check", acViewNormal, , strWhere
End If
End Sub
I'm not sure if i'm going about all this in a best way, so if there are any easier/slicker ways to do this please enlighten me.
Thanks in advance for any help.