Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning Value To Form Field (Access 2003)

    I have a form that records incoming shipments. This form is based on the table tbl_incomingshipments and has the PK of IncomingShipmentID. When the user click OK, the IncomingShipmentID is generated (by automnumber) and an Inventory Form open. This inventory form is based off the tbl_Inventory, including a field for the IncomingShipmentID.

    What I want to do is have the IncomingShipmentID on the Inventory Form to equal the IncomingShipmentID from the Incoming Shipment Form when the Inventory Form opens. I always get an error unless I remove the controlsource from the IncomingShipmentID on the Inventory Form.

    Currently I have:
    Private Sub Form_Open()
    me.incomingshipmentID = Form!FRM_IncomingShipments!IncomingShipmentID
    End Sub

    Any ideas how I can get this to work without removing the controsource value in the IncomingShipmentID on the Inventory Form?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assigning Value To Form Field (Access 2003)

    The On Open event occurs too early, before records have been loaded. You should use the On Load event instead of the On Open event.

    I assume that IncomingShipmentID is not an AutoNumber field in tbl_Inventory, for if it is, you can't set its value.

    You should open the inventory form to a new record, otherwise you'll just be changing the IncomingShipmentID of the first record in the form.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning Value To Form Field (Access 2003)

    Thanks!. I was just trying to assign the value to early. I moved the code to the Form_Load() and everything works [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •