Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44

    Form 1 code continues to run when opening popup/modal form2

    I have two forms - Form1 and Form2. Form2 is defined with Popup and Modal properties set to Yes. When I use the following -



    stDocName = "Form2"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Set rstIssues = CurrentDb.OpenRecordset("SELECT DISTINCT * FROM Issues WHERE TTP_No = " & lngSelectedTTP)

    With rstIssues

    Form2 is not displayed, and the Form1 code continues thru the Set and With. I thought if a Form2 is set to Modal/Popup, it would be displayed, and the code in Form1 would wait until Form2 is closed. Is that not the case? That is what I need it to do, because the field lngSelectedTTP is populated in Form2.

    Sorry, this is Access 2007.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    I would use acDialog in the window mode argument of OpenForm.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    pbaldy is right - Access tends to ignore the modal/popup settings when you open the form through VBA, and you have to use acDialog mode. Doing that will pause the code as you expect.

    John

  4. #4
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Still not getting Form2 to show.

    And now, a new problem has surfaced. I have the following code for an Exit button.

    Private Sub cmdExit_Click()
    DoCmd.Quit acQuitSaveAll

    End Sub

    I copied it from another database. When I click on the Exit button in the other database, Access is completely closed. No problem. When I click on the Exit button in my new database, I get this :

    Click image for larger version. 

Name:	Exit_issue.jpg 
Views:	13 
Size:	38.4 KB 
ID:	17081



    Same code, different databases (both created with Access 2007), different results. Why?

    More on this - I get this error on anything that has [Event Procedure] on an event. Even the On Load event for the form. In the Form_Load code, I don't have any code. It is empty. And, I still get this error. And, to top it all off, all of these buttons were working, early this morning.

    I have tried closing/re-opening Access. Created a blank database, and imported the old into it. Nothing worked.

  5. #5
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Can anybody give me a solution, or at least, point me in direction of the solution?

  6. #6
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    It's bit of a shot in the dark, but might you have a code error somewhere?

    Open any code module, then from the menu, select Debug - Compile.

    I have seen compile errors lead to totally misleading error messages.

    HTH

    John

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    You might also try decompiling the db.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    That did it! I found the problem - I was trying to use a field type of DateTime. Apparently, VBA doesn't like that.

    Thanks, John_G! And everyone else, too.

  9. #9
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    But, wait! Now, back to the original issue (See original post.) - I am still unable to get the called form to display, and pause the code in Form1.

    stDocName = "TTP_Find"
    DoCmd.OpenForm stDocName, , stLinkCriteria, , , acDialog
    Set rstIssues = CurrentDb.OpenRecordset("SELECT DISTINCT Requestor, Status, ShortDescription, LongDescription, Priority, System, AssignedTo FROM Issues WHERE TTP_No = " & lngSelectedTTP)

    With rstIssues
    txtTTP_No = CStr(lngSelectedTTP)
    txtRequestor = .Requestor
    cboStatus.Value = .Status
    txtShortDescription = .ShortDescription
    txtLongDescription = .LongDescription
    cboPriority.Value = Priority
    cboSystem.Value = .System
    txtAssignedTo = .AssignedTo
    End With

    It doesn't display the "TTP_Find" form, but continues on and stops in the With, on the highlighted field, displaying

    Click image for larger version. 

Name:	not_found issue3.jpg 
Views:	13 
Size:	14.3 KB 
ID:	17105

    I have used both - * and the fields explicitly listed. They both give this error. But, that IS the name in the table, and in the RecordSet. NOW what am I doing wrong?

  10. #10
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    It would be

    !Requestor

    Does the form open if you double click on it from the nav pane? Is there code running in the open event that may stop it from opening?

    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Just to elaborate on pbaldy's note -

    With each new version, Access has become less and less tolerant of using rstIssues.Requestor vs rstIssues!Requestor. Sometimes it works, sometimes not.

    You should always make it a practice to use the ! whenever you refer to a recordset member or Form control (Forms!FormName!Controlname or Me!Controlname)

    Try putting a msgbox confirmation in the On Open event of the second forn to confirm the code actually is running. As pbaldy suggested - is there code in the second form that maight be canceling the on open or on load?

  12. #12
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Ok, both forms are showing now. Back to the original problem again - Form 1 code is proceeding instead of pausing, while Form 2 has the focus. Form 2 is being called like this -

    stDocName = "TTP_Find"
    DoCmd.OpenForm stDocName, , , , , acDialog

  13. #13
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    That looks correct; try turning off the modal/popup settings of the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Tried turning off the modal/popup settings - same result as having them on.

  15. #15
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-21-2014, 06:37 PM
  2. Command continues to popup message box..
    By Stephanie53 in forum Forms
    Replies: 12
    Last Post: 05-30-2013, 02:23 PM
  3. Close Button for Popup, non-modal from
    By P5C768 in forum Forms
    Replies: 3
    Last Post: 04-09-2013, 01:43 PM
  4. Replies: 1
    Last Post: 03-20-2013, 07:04 AM
  5. popup when opening a form
    By ajetrumpet in forum Forms
    Replies: 1
    Last Post: 10-08-2010, 09:33 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