Results 1 to 4 of 4
  1. #1
    mismag is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2019
    Location
    California, US
    Posts
    58

    Sub form not closing when I click on the New record button

    Hi,



    With the help of this forum members I have been able to create a database and forms to enter the data into the database.
    In my form there are 2 sub-forms.
    Based on the selection of combo box value, corresponding sub form opens.

    Title:- "F&I Manager" then sub-form 1 opens.
    Title:- "Sales Manager" then sub-form 2 opens.

    My problem here is, when I finish entering data once and click on the new record button in the bottom left corner, My sub-form doesn't close.
    Attached is the code for the form and sub forms.

    Any help is greatly appreciated.
    Attached Thumbnails Attached Thumbnails Capture.PNG  

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    Kinda confusing. You're calling a routine that makes 2 subforms visible, or not. Nowhere do you code to close a subform, yet you say you want one to close. Your IF on the variable "Title" looks incomplete as well. How is this determined, as I see no evidence of how the code makes that decision? In the current event, you make title "", yet in the sub you don't check for "". Nor do you pass the title value to the sub, even if it is "". Maybe explain more about what's supposed to happen when, and why.

    Note - it's far easier for us if you post nicely indented code within code tags rather than a picture. To make significant re-writes, we have to write everything out when we could be copying text. Thanks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In the current event you're calling the sub before setting the combo to "", so the previous value is still there. Set the combo first.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    My problem here is, when I finish entering data once and click on the new record button in the bottom left corner, My sub-form doesn't close.
    Try something like:
    Code:
    Private sub Form_Current()
        if me.newrecord then
            Title=""
            call ShowSubform
            exit sub
        end if

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

Similar Threads

  1. Replies: 2
    Last Post: 04-06-2017, 05:22 AM
  2. Replies: 1
    Last Post: 09-07-2014, 10:15 PM
  3. Replies: 1
    Last Post: 08-21-2014, 02:29 PM
  4. Closing a Form with a Command Button
    By JoeM in forum Forms
    Replies: 5
    Last Post: 06-21-2012, 11:28 AM
  5. Replies: 4
    Last Post: 07-22-2011, 12:52 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