Results 1 to 2 of 2
  1. #1
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143

    .DefaultValue works only half the time.

    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!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    When opening frmPurchases by Way Two, where would PurID come from? Is this an autonumber field? This new record must first be committed to table before the new PurID is available for frmLotDetails.

    Record is committed when: 1. close table/query/form, or 2. move to another record, or 3. run code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. sendobject works only one time
    By absolutegrinding in forum Access
    Replies: 1
    Last Post: 05-24-2017, 08:03 AM
  2. Replies: 4
    Last Post: 01-25-2016, 12:44 PM
  3. Replies: 1
    Last Post: 06-21-2015, 07:58 AM
  4. Replies: 8
    Last Post: 04-23-2015, 06:12 AM
  5. Round up time half an hour
    By JBM18 in forum Queries
    Replies: 2
    Last Post: 12-09-2010, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums