Results 1 to 3 of 3

Thread: Modeless form with "Cancel" button
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Sep 2015
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Modeless form with "Cancel" button

    I have a following situation.
    Form1 runs a printing routine after clicking OK.
    Then Modeless form Form2 shows up with info what is being printed now.
    I need a cancel button on Modeless form Form2 to stop all remaining tasks and exit.
    At the moment cancel button in Form2 I have cannot be clicked when printing job is being done, so don't even know if End I have will work to stop procedures running .

    A simplified version of what I have:

    In Form1 - OK Button:
    Code:
    Private Sub ButtonOK_Click()
    Me.Hide
    Form2.Show
        For i = 1 To ItemsQty
                        Form2.Label1.Caption = "Item " & i
                        PreparePrintout(i)
                        PrintToNetworkPrinter
       Next i
    Form2.Hide
    Unload Form2
    Unload Form1
    End Sub
    In Form2 - Cancel button:
    Code:
    Private Sub ButtonCancel_Click()
    Unload Form1
    Unload Form2
    End
    End Sub

  2. #2
    Board Regular bobsan42's Avatar
    Join Date
    Jul 2010
    Location
    Bulgaria, GMT+2 (42.891813,25.313594)
    Posts
    1,281
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Modeless form with "Cancel" button

    try to put DoEvents in between separate procedures to see if this helps.
    The other thing to check is if you can interact with form2 even when no code is running ?
    "...it's sad that in our blindness we gather thorns for flowers..."
    mostly using:
    windows 7 +10 (64-bit) / excel 2013 +2016 (32-bit) / access 2013 +2016 (32-bit) / some imagination & Google of course
    You don't need to read between the lines - just read them all!

  3. #3
    New Member
    Join Date
    Sep 2015
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Modeless form with "Cancel" button

    Quote Originally Posted by bobsan42 View Post
    try to put DoEvents in between separate procedures to see if this helps.
    The other thing to check is if you can interact with form2 even when no code is running ?
    Wow.. DoEvents worked like a charm...
    Before that Label.Caption had been updated every random for loop, but now it displays every single iteration...

    I have to read a little bit about DoEvents to know exactly what it does

    Thanks.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •