Results 1 to 3 of 3
  1. #1
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Command Button Enable/Disable (2000+)

    I have some code that repeatedly runs when a command button is clicked until the same button is clicked again.

    I want the other buttons to be disabled and this works in a fashion. When I click on cbContUD, it turns red as it should, calls ContUpdate, and then the other buttons turn grey.

    Is there a way to get them to be shown as disabled immediately? (Stepping through the code they are disabled immediately.)

    <pre>Private Sub cbContUD_Click()

    If fStop = True Then
    cbPrint.Enabled = False
    cbData.Enabled = False
    cbHistory.Enabled = False
    cbSave.Enabled = False
    cbSettings.Enabled = False
    fStop = False
    cbContUD.BackColor = &HFF&
    cbContUD.ForeColor = &H80000009
    cbContUD.Caption = "Cancel Update"
    cbContUD.Shadow = True

    ContUpdate

    Else
    fStop = True
    cbContUD.ForeColor = &H80000012
    cbContUD.Caption = "Cont. Update"
    cbContUD.Shadow = False
    cbPrint.Enabled = True
    cbData.Enabled = True
    cbHistory.Enabled = True
    cbSave.Enabled = True
    cbSettings.Enabled = True
    cbContUD.BackColor = &H8000000F
    End If

    End Sub</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Command Button Enable/Disable (2000+)

    Try inserting one, or if necessary two or three, lines

    DoEvents

    before calling ContUpdate.

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Command Button Enable/Disable (2000+)

    Two lines does it - thanks!

Posting Permissions

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