Results 1 to 7 of 7
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365

    Form not bcoming modal as expected


    Code:
     DoCmd.OpenForm "frmPending", acFormDS, , , , acDialog
        
        Stop
    With the Form open I expected code execution to Stop until the Form was Closed, but it continues immediately to the Stop Instruction
    Form Properties are set To Modal and Popup.
    What am I doing wrong that sees this happen ?

  2. #2
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    could it be datasheet view?

    The form isn't a pop-up form in Design view or Datasheet view, and also isn't if you switch from Datasheet view to Form view.
    https://learn.microsoft.com/en-us/of...ess.form.popup
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Yes, it was datasheet view. Bit of a shame, and I suppose no other method exists to halt code execution until the Form is closed?

  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I suppose no other method exists to halt code execution until the Form is closed?
    Depends on what you want to do. I assume you want to open the form, do something, then run some code when the form closes.

    You could possibly use withevents and a custom event. Make sure your pop up has the HasModule property set to yes.

    This is aircode. It all goes in your calling form. Edit the name of popup as needed.

    Code:
    Dim WithEvents MyForm as access.form
    
    Private sub SomeButton_Click()
    
         Docmd.OpenForm "YourPopUpFormName"
    
         Set MyForm = Forms("YourPopUpFormName")
    
         MyForm.OnClose = "[Event Procedure]"
    
    End Sub
    
    Private Sub MyForm_Close()
    
         'Run your code here.
    
    Set MyForm = Nothing
    
    End Sub
    EDIT: I should also tell you don't open as dialog, set the modal property of the pop up to yes.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Here's an example using withevents for a form, a textbox, and a command button
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Thanks vey much, about to try it in my db. I was not aware of WithEvents.

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Try putting your datasheet form as a subform to another form and open that instead?

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

Similar Threads

  1. Print preview modal form
    By data808 in forum Forms
    Replies: 10
    Last Post: 03-10-2014, 02:32 AM
  2. Using a modal form
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 10-21-2013, 01:29 PM
  3. Modal Form Operator
    By mm07nkb in forum Forms
    Replies: 5
    Last Post: 09-01-2011, 10:53 AM
  4. Replies: 1
    Last Post: 02-17-2011, 06:23 AM
  5. Replies: 6
    Last Post: 02-10-2011, 09:58 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