I have a purchase order form [frmPurchases] with a button that opens form [frmLotDetails] to add records in a parent/child fashion. (It's not a subform because the subform has a subform and this way looks cleaner). The button code is as follows:
Code:
DoCmd.OpenForm "frmLotDetails"
DoCmd.GoToRecord , , acNewRec
Forms!frmlotdetails!PurID.Visible = True
Forms!frmlotdetails!PurID.DefaultValue = Me.PurID
There are two ways of opening frmPurchases.
Way One: frmPurchaseList is a continuous form with a list of purchase orders. Clicking on a purchase order will open the form to that order. Code as follows:
Code:
DoCmd.OpenForm "frmPurchases", , , "PurchaseNumber =" & Forms!frmpurchaselist!PurchaseNumber
This works fine and when I open frmLotDetails, the PurID is populated correctly.
Way Two: frmLotList is a list of our current inventory. When a user needs to add a new inventory item they click on a button that gives a drop down menu to select whether the new item was produced in-house or purchased. If "purchased" is selected it will open frmPurchases to a new record:
Code:
DoCmd.OpenForm "frmPurchases"
DoCmd.GoToRecord , , acNewRec
When the form is opened using Way Two, and the button to add records is clicked, the PurID is not populated and has no default value. I haven't got a clue why this happens and need it to work when opening from frmLotList as this is more common.
I probably gave more information than necessary. I just want to make sure that it's all laid out since I don't know where the problem is.
Thank you in advance for your help!