Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208

    Force form to appear


    I have a form displayed in dialog mode, and in the form's Load event, under certain conditions, I immediately call another dialog form.

    When I do that, the first dialog form does not display. Some parts of it do, like a combobox that is forced to DropDown, and sometimes random bits of other things, sometimes nothing, but the form does not display as a whole. The second form appears first, and only after I deal with it and close it, does the first dialog form finish displaying.

    I have tried DoEvents, Form.RePaint, Form.Refresh, Sleep - nothing works.

    I am thinking I may have to try setting a timer in the Load event and let the event finish, then have the timer event open the second form, if the display is somehow dependent on the Load code completing, but that seems a bit clunky.

    Is there some other way to force the display to finish painting BEFORE going on to open the second form?

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I have a form displayed in dialog mode, and in the form's Load event, under certain conditions, I immediately call another dialog form.
    Have you tried other events such as OnCurrent for the 2nd form?
    It would also help to see your code.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Have you tried other events such as OnCurrent for the 2nd form?
    It would also help to see your code.
    What would I put in the OnCurrent event of that second form? I have already executed code to open the first form, and it runs properly, just doesn't finish painting the display.

    As for my code, it is completely straightforward:
    Code:
    DoCmd.OpenForm "PodrobnostiSetDrEvid", acNormal, , , , acDialog
    called as the last statement in the first form's OnLoad event.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Have you tried opening the second form using the OnCurrent event of the first form rather than the OnLoad event.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    What would I put in the OnCurrent event of that second form?
    FOR the second form. Opening the 2nd form from the OnCurrent of the first form.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Ah, okay. No, I haven't tried the Current event. We're down for the weekend, but I'll try it Monday morning.

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    You should also consider rebuilding the form as that's not normal behavior.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  8. #8
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    FOR the second form. Opening the 2nd form from the OnCurrent of the first form.
    Just tried it - no luck. Called from the OnCurrent event code, it behaves the same way: first form does not appear. The second appears, and only after closing the second form does the first form finish displaying properly.

  9. #9
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    You should also consider rebuilding the form as that's not normal behavior.
    Not sure about that. I just tried creating a completely new database, containing only three forms: Form0, Form1 and Form2. Form0 has a single command button, which calls Form1 the same way as my problem database. Form1 has a single line of code in its OnLoad event, which calls Form2. The behavior is exactly the same - Form1 does not appear. Instead Form2 appears, and Form1 appears only after Form2 is closed.

    Same when it's called from Form1's OnCurrent event.

    It seems ridiculous to me, but that is what's happening.

  10. #10
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    So I got it working with a timer. As the last statement in the first form's OnLoad event, I put TimerInterval = 50, in the Timer event I put TimerInterval = 0 and then call the second form. Seems an incredibly retarded way to have to do it, but it's working.

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Have you tried modal forms rather than dialog as dialog pauses the code?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #12
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Have you tried modal forms rather than dialog as dialog pauses the code?
    Yes, that also works, but in this app, I need both forms to operate in dialog mode. I understand dialog mode halts the calling VBA code - that's why I use it here. But I rather expected the form to be displayed. Maybe the OnLoad event should properly be called BeforeLoad, or DuringLoad. I expected that OnLoad would mean when it has done the load, but I suppose that's just a quibble.

    However, I don't understand why the OnCurrent variant didn't work. At that point, I would certainly expect all start-up chores to have been completed.

  13. #13
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I need both forms to operate in dialog mode.
    Why? You'll only be able to use the 2nd form until you close it. Then the 1st will be active.

    Are you running code after the pause from acDialog?

    Trying to pause code to pass info between forms? There are other ways.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #14
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Why? You'll only be able to use the 2nd form until you close it. Then the 1st will be active.

    Are you running code after the pause from acDialog?

    Trying to pause code to pass info between forms? There are other ways.
    The first dialog form is called by a user action on the main form, from which all action originates. The first dialog form looks for a certain set of conditions, and when those are met, opens the second form. The user clicks a selection there, which performs a specific task and automatically closes itself and returns to the first dialog form, which is what the user intentionally opened.

    However, there are things ON the first form that the user may want to see, which will affect what choices he makes on the second form. That is why I need that first form to finish painting.

    Not sure what you mean by 'pause from acDialog'. I don't have any pause. Well, actually, I do now - 50 milliseconds for the timer event, which is what it took to get this working properly. Otherwise, no - the second form is called immediately from the first form.

    Yes, there is some info passed between the two forms, but that all works. I do not need to pause for any of that to happen.

  15. #15
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658

    Screen shot of forms please?

    I didn't read all the post and suggestions just the first few.
    Once you start your second form with acDialog, all code processing stops in the first form until the second form closes. (I think you know that)
    From my experience, it doesn't matter in which procedure you open the second form, the first one stops.
    That's what acDialog does.

    There is a way around this, using doevents, but in my experience, processing will return to the first form and finish there, ignoring the second form even if it has code running. All this is referering to VBA code running. I've yet to figure out the logic of Access when it's doing its own thing between VBA procedures. If you step through the procedures code, you'll see some very strange stuff going on with the way Access calls procedures, often many times without reason.
    The timer, as you found, is another way to force the first form to respond, I use it to shutdown forms on command from the system administrator, not like you are.

    I have lots of forms that call a search form. A command button calls the search form, but only after the first form is completely open and the first record is displayed, meaning all initial procedures have run. Sometimes I have a lot of procedures running before a form displays. In my experience, any form won't display until the Form_Current terminates. I just did a test with one of my forms, calling a wizard created form (as simple as it can get) at the end of the Form_Current procedure, and the first form won't display anything until the wizard called form closes. It probably depends on what your particular form is doing and how much is getting done before you open the second form. So, I would like to see what your screen looks like when you open the form without a timer.

    Despite all the above, why not disable a command button at startup, then if your conditions are met, enable the command button after you've completely opened the first record on the first form, so the user can do their thing on the supporting form? Wouldn't that make sense if they need to see things on the first form to make decisions for the second form?

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

Similar Threads

  1. Force a user to enter data on a form
    By easyrider in forum Programming
    Replies: 2
    Last Post: 02-01-2022, 11:07 AM
  2. Replies: 2
    Last Post: 08-26-2021, 06:10 PM
  3. Replies: 8
    Last Post: 02-28-2012, 09:05 PM
  4. Force form to skip records
    By allenom in forum Access
    Replies: 2
    Last Post: 10-05-2011, 05:52 AM
  5. Force form not to save updated fields
    By Evgeny in forum Programming
    Replies: 2
    Last Post: 04-30-2010, 10:44 PM

Tags for this Thread

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