ailyn
11-03-2005, 03:25 AM
me again!:hi:
Thanks to Geekgirlau I have discovered the marvels of using the wizard for making simple code. It solved so many problems that the macro couldn't solve!
But now I have a complicated query that the wizard can't solve. I have a form with a subform that I open whenever I make an order from products, but it doesn't show the product because it is in the subform!
Here is a better explanation (all my fields in the form have the original name of the table values):
FormNewOrder:
orderId
SellerId
CustomerId
VAT
Discount
Charges
Total (unbound Sum)
Subform:
orderdetailsId
orderId(bound it to the FormNewOrders)
productId(see FormProducts)
location (seeFormProducts)
ref
motorId
price
extras
...
--------------
FormProducts:
ProductId
location
ref
...
This is the code from the FormProducts (made thanks to the wizard):
Private Sub OpnFormNewOrder_Click()
On Error GoTo Err_OpnFormNewOrder_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormNewOrder"
stLinkCriteria = "[ProductId]=" & Me![ProductId]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
DoCmd.Close acForm, "FormProducts"
Exit_OpnFormNewOrder_Click:
Exit Sub
Err_OpnFormNewOrder_Click:
MsgBox Err.Description
Resume Exit_OpnFormNewOrder_Click
End Sub
I understand why it doesn't work, but how can I make it work?
Thanks to Geekgirlau I have discovered the marvels of using the wizard for making simple code. It solved so many problems that the macro couldn't solve!
But now I have a complicated query that the wizard can't solve. I have a form with a subform that I open whenever I make an order from products, but it doesn't show the product because it is in the subform!
Here is a better explanation (all my fields in the form have the original name of the table values):
FormNewOrder:
orderId
SellerId
CustomerId
VAT
Discount
Charges
Total (unbound Sum)
Subform:
orderdetailsId
orderId(bound it to the FormNewOrders)
productId(see FormProducts)
location (seeFormProducts)
ref
motorId
price
extras
...
--------------
FormProducts:
ProductId
location
ref
...
This is the code from the FormProducts (made thanks to the wizard):
Private Sub OpnFormNewOrder_Click()
On Error GoTo Err_OpnFormNewOrder_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormNewOrder"
stLinkCriteria = "[ProductId]=" & Me![ProductId]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
DoCmd.Close acForm, "FormProducts"
Exit_OpnFormNewOrder_Click:
Exit Sub
Err_OpnFormNewOrder_Click:
MsgBox Err.Description
Resume Exit_OpnFormNewOrder_Click
End Sub
I understand why it doesn't work, but how can I make it work?