Results 1 to 8 of 8
  1. #1
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81

    Subform Master Child prompt before defined

    Hi All,

    I'm stuck while trying to open a new form from a button press. I'd like to open a form, lets call it "Input Form" from another form, "Main Form".


    • Input form has a subform with a list of comments linked to a separate table, I'll call the subform "Comment Form".
    • Comment form is linked to Input form by a field in both record sources called "BATCH", and both Master and Link Child fields are set to BATCH


    When I click the button on the Main Form to open Input Form, I get a prompt to enter a value for BATCH and I can't for the life of me figure out why. It is clearly trying to link the subform "Comment Form" with the Input Form before I set the value of BATCH on the "On Open" event. I put a msgbox("here") statement at the top of the "On Enter" event, but I get prompted for BATCH before I get the "here" message.

    What am I missing?



    (Image of Input Form attached)
    Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	21.7 KB 
ID:	49403
    Last edited by virgilio; 01-03-2023 at 11:30 AM. Reason: changed On Enter to On Open

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    is the table field actually called BATCH on both tables?
    is the text box actually called BATCH on both forms?

  3. #3
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81
    is the table field actually called BATCH on both tables? Yes
    is the text box actually called BATCH on both forms? No, I'm not using the BATCH field on either form. I'm just using that field in the table to link Master and Child.

    TBH, I'm using a previous project that I made about a year ago as a template and this works perfectly there. I just can't see what I'm doing wrong.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Subforms load before mainforms?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    Subforms open and load before the main form, so something in your code is causing this. If you can move that to the main form you should be OK.
    Dang! Late to the party again.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CarlettoFed is online now Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    274
    Attach a sample file so you can see what you've made.

  7. #7
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81
    I put a message box into the open event on the subform [MsgBox ("subform open")], and I still get prompted for BATCH before I get the "subform open" message.

  8. #8
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81
    Solved, It looks like I just needed something in the Record Source of the Property Sheet for the Input form. It doesn't look like it is doing anything so I left it blank in the new version. IOW, The BATCH prompt quit when I filled Record Source in with a SQL query that is unrelated to the rest of the form. I guess Properties is being overwritten by VBA after everything is loaded.

    Thank you all for your help.

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

Similar Threads

  1. Replies: 14
    Last Post: 12-01-2015, 02:55 PM
  2. Replies: 1
    Last Post: 03-21-2014, 06:17 AM
  3. Replies: 5
    Last Post: 03-30-2013, 12:56 PM
  4. Replies: 1
    Last Post: 02-20-2012, 01:59 PM
  5. Replies: 2
    Last Post: 06-14-2010, 03:25 PM

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