Hi there
I would like my users to be able to view stock items in one (sub)form and when they double click on an item, then certain data is copied to an orders (sub)form.
I have therefore embedded two unbound subforms into a master form.
The master form (Frm Stock) has no fields, but it has 2 subforms.
Frm_Stock_Subform and Frm_OrderDetail_Subform
So I have 2 problems here.
Problem 1
I would like the following code trigger when the user double clicks anywhere on the record that the user wants to order.
Thus far, I can only make it fire only when the user doubl;es clicks in a specific field (in this case, the ID field is the trigger)
Problem 2
I cannot activate the Frm_OrderDetail_Subform in order to create the new record. (I have looked at this link - Refer to form and subform
Or should I consider another solution?
Thanks for assistance
I would like my users to be able to view stock items in one (sub)form and when they double click on an item, then certain data is copied to an orders (sub)form.
I have therefore embedded two unbound subforms into a master form.
The master form (Frm Stock) has no fields, but it has 2 subforms.
Frm_Stock_Subform and Frm_OrderDetail_Subform
So I have 2 problems here.
Problem 1
I would like the following code trigger when the user double clicks anywhere on the record that the user wants to order.
Thus far, I can only make it fire only when the user doubl;es clicks in a specific field (in this case, the ID field is the trigger)
Problem 2
I cannot activate the Frm_OrderDetail_Subform in order to create the new record. (I have looked at this link - Refer to form and subform
Or should I consider another solution?
Code:
Private Sub ID_DblClick(Cancel As Integer)
On Error GoTo Err_ID_DblClick
Dim MyOrderID As Variant
Dim MyStockID As Variant
Dim MyAmt As Variant
Dim MyDesc As Variant
Dim MyAccCde As Variant
Dim MyVendID As Variant
Dim MyVendName As Variant
''pick up the field values from the Frm_Stock_Subform
MyOrderID = Me.ID
MyStockID = Me.ItemCode
MyAmt = Me.VendorPrice
MyDesc = Me.Description
MyAccCde = Me.Acc
MyVendID = Me.VendorID
MyVendName = Me.VendorName
''Make the target (Frm_OrderDetail_Subform) active to append values.
' - - - - -NONE of the following 5 lines of code works for me
Me!Frm_Stock_subform.Form!Frm_OrderDetail_subform!OrderID.SetFocus
Me!Frm_OrderDetail_subform.Form!OrderID.SetFocus
Me!Frm_OrderDetail_subform!OrderID.SetFocus
Forms!Frm_OrderDetail_subform.OrderID.SetFocus
Forms!Frm_Stock!Frm_OrderDetail_subform.OrderID.SetFocus
'Add a new blank record
RunCommand acCmdRecordsGoToNew
'' Update the values
Me.ID = MyOrderID
Me.ItemCode = MyStockID
Me.VendorPrice = MyAmt
Me.Description = MyDesc
Me.Acc = MyAccCde
Me.VendorID = MyVendID
Me.VendorName = MyVendName
'' Set focus to the QTY field so that user can type in the quantity needed
Me.Quantity.SetFocus
Exit_ID_DblClick:
Exit Sub
Err_ID_DblClick:
MsgBox Err.Description
errnum = 0
Resume Exit_ID_DblClick
End Sub
Thanks for assistance