Results 1 to 15 of 15
  1. #1
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    365

    Opening Dayasheet Form acDialog doesl not halt code excecution

    Code:
    DoCmd.OpenForm "Form1", View:=acNormal, WindowMode:=acDialog
    Stop
    Stop does not execute until I close the Form

    But this fails. Stop executes immediately


    Code:
    DoCmd.OpenForm "Form1", View:=acFormDS, WindowMode:=acDialog
    Stop
    Is this correct? Is there anyway for a Datasheet form halt code until closed ?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Code execution of main form is suspended with the acDialog parameter. The second form must close then main form code resumes execution.

    What do you expect? Why are you trying to use Stop? Exactly what are you trying to stop?
    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.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by June7 View Post
    Code execution of main form is suspended with the acDialog parameter. The second form must close then main form code resumes execution.

    What do you expect? Why are you trying to use Stop? Exactly what are you trying to stop?
    But that doesn't seem to be the case if the form is opened in datasheet view
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    This is how I understand it:
    You can't switch a popup form from form view to any other view, even with code, and a form isn't a popup in design or datasheet view. So my guess is that by using datasheet view, you over-ride the modal effect. That would be because acDialog sets the popup and modal properties to True. If you can't set both to true, my guess is that acDialog doesn't work but the form or code doesn't complain either.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Micron View Post
    ... my guess is that acDialog doesn't work but the form or code doesn't complain either.
    If acDialog doesn't work would you consider that to be a fault/bug?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    I think so. I mean, shouldn't the vbe compiler at least mention that the dialog parameter isn't compatible with the form view chosen?
    Don't forget that what I said is a guess, based on the documentation saying (at least how I interpret it) datasheets can't be popups and that acDialog sets modal and popup properties. The fact that the code doesn't wait for the "modal" form seems to suggest that. I would try it this way to see if it makes any difference, but don't expect the same results if you open the form from the nav pane:

    DoCmd.OpenForm "Form1",acFormDS,,,,acDialog

    Apparently, that worked 15 years ago, but the documentation is much more recent so I don't hold out a lot of hope for that working.

    EDIT - I think the common solution to the problem has been to make the form continuous but look like a datasheet.
    Last edited by Micron; 09-05-2022 at 11:32 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Okay, learned something new. I've never used acDialog with form in datasheet view.
    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.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by June7 View Post
    Okay, learned something new.
    Me too. Trouble is I seldom remember anything now that I'm old
    Quote Originally Posted by June7 View Post
    I've never used acDialog with form in datasheet view.
    It would appear that nobody has . Well not with any success
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    365
    Interesting. I used datasheet mode as there's multiple records and I want to to select one of them. Maybe a continuous Form would work but I've never used one or seen how its designed.
    Is this perhaps something to try ?

    DoCmd.OpenForm "Form1", View:=acFormDS
    do
    do events
    loop until "Form1 closes"
    stop

    I don't yet has a routine to detect if the Form1 is closed or not.
    @June asked what the Stop is For? To stop the code so I can test/see its working.
    Isn't modal to force the Form to be closed. Does that stop code the same way as acDialog for non-datasheet Forms ?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I should have said "I never tried to use acDialog with a Datasheet form."

    Make a continuous form look like datasheet by positioning textboxes and comboboxes against each other and minimizing height of Detail section.

    Lose ability to manually adjust width of columns because there aren't any.
    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.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    OK ... second bit of strange behaviour I've experienced today
    I've just tried opening a datasheet form using acDialog in both A2010 & A365 and got this result

    Click image for larger version. 

Name:	DialogDSForm.png 
Views:	14 
Size:	57.3 KB 
ID:	48638

    The tiny form that appeared couldn't be enlarged. All I could do was close it!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Test with form that is set as Datasheet for DefaultView.

    DoCmd.OpenForm "Games", , , , , acDialog

    Form opens displaying a single record in Datasheet

    DoCmd.OpenForm "Games", acFormDS, , , , acDialog

    Form opens displaying all records in Datasheet.

    And when form is not set as Datasheet in DefaultView, form opens just fine when using acFormDS and acDialog.

    I confirm that if DefaultView is set to Datasheet and/or acFormDS is used, acDialog is ignored.
    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.

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    when form is not set as Datasheet in DefaultView, form opens just fine when using acFormDS and acDialog.
    In that case is 'acDialog ignored', which I take to mean that code doesn't halt because it doesn't behave as a modal form?
    Thanks for doing that testing, BTW.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by isladogs View Post
    OK ... second bit of strange behaviour I've experienced today
    I've just tried opening a datasheet form using acDialog in both A2010 & A365 and got this result

    Click image for larger version. 

Name:	DialogDSForm.png 
Views:	14 
Size:	57.3 KB 
ID:	48638

    The tiny form that appeared couldn't be enlarged. All I could do was close it!
    Yes I got that when I was playing around with it yesterday but, as I'm sure you'll already know, using: Docmd.Restore as the next line after the line that opens the form, will give a useable form. Yet another indication that the acDialog does not work.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    365
    Very nice of everyone to offer ideas. I have found I can simulate acDialog for a data sheet Form as in Msg #9.
    Code:
    DoCmd.OpenForm "Form1", acFormDS
      Do
      DoEvents
      Loop Until CurrentProject.AllForms("Form1").IsLoaded = False
    This allows click events in Form1 to be used.
    I didn't add acDialog as it has no effect

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

Similar Threads

  1. Replies: 4
    Last Post: 04-24-2021, 02:04 PM
  2. Replies: 0
    Last Post: 03-06-2019, 12:52 AM
  3. acDialog not pausing code
    By mredmond13 in forum Programming
    Replies: 8
    Last Post: 07-08-2018, 01:31 PM
  4. How to halt continued execution
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 01-04-2016, 09:48 PM
  5. Replies: 8
    Last Post: 05-06-2013, 03:14 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