+ Reply to Thread
Results 1 to 4 of 4

warning message

  1. #1
    Mike
    Guest

    warning message

    Hi In my worksheet i have 2 sets of buttons, is there a way of preventing
    one set of buttons being used until one of the other set has been pressed
    first, maybe a warning message

  2. #2
    Kevin B
    Guest

    RE: warning message

    You can set the enabled property of the second command button to false and in
    the code module for the first command button you can use this to activate the
    button:

    Private Sub CommandButton1_Click()

    If Not Me.CommandButton2.Enabled Then
    Me.CommandButton2.Enabled = True
    End If

    End Sub

    --
    Kevin Backmann


    "Mike" wrote:

    > Hi In my worksheet i have 2 sets of buttons, is there a way of preventing
    > one set of buttons being used until one of the other set has been pressed
    > first, maybe a warning message


  3. #3
    Mike
    Guest

    RE: warning message

    Hi Kevin thanks for reply, I have 10 buttons labelled £1, £2 £3 and so on
    and then 8 buttons i need to make sure one of the 10 (£)buttons has been
    pressed before any of the 8 buttons, hope that makes sense

    "Kevin B" wrote:

    > You can set the enabled property of the second command button to false and in
    > the code module for the first command button you can use this to activate the
    > button:
    >
    > Private Sub CommandButton1_Click()
    >
    > If Not Me.CommandButton2.Enabled Then
    > Me.CommandButton2.Enabled = True
    > End If
    >
    > End Sub
    >
    > --
    > Kevin Backmann
    >
    >
    > "Mike" wrote:
    >
    > > Hi In my worksheet i have 2 sets of buttons, is there a way of preventing
    > > one set of buttons being used until one of the other set has been pressed
    > > first, maybe a warning message


  4. #4
    Kevin B
    Guest

    RE: warning message

    You can place those 8 buttons in an array, and then place it in the on click
    event for the £1, £2 £3 buttons et al. It's not the most efficient, but it's
    the shortest way I can think of right now to convey how to do it. You write
    a single block of code in a module and then execute just that code for each
    of the buttons (£1, £2 £3) but I'm short on time at the moment.

    Hope this helps

    Private Sub CommandButton1_Click()

    Dim cmd1 As CommandButton
    Dim cmd2 As CommandButton
    Dim cmd3 As CommandButton
    Dim cmd4 As CommandButton
    Dim cmd5 As CommandButton
    Dim cmd6 As CommandButton
    Dim cmd7 As CommandButton
    Dim cmd8 As CommandButton

    Dim varArray As Variant
    Dim varButtons As Variant

    Set cmd1 = Me.CommandButton1
    Set cmd2 = Me.CommandButton2
    Set cmd3 = Me.CommandButton3
    Set cmd4 = Me.CommandButton4
    Set cmd5 = Me.CommandButton5
    Set cmd6 = Me.CommandButton6
    Set cmd7 = Me.CommandButton7
    Set cmd8 = Me.CommandButton8

    varArray = Array(cmd1, cmd2, cmd3, cmd4, cmd5, cmd6, _
    cmd7, cmd8)
    varButtons = varArray

    For Each varButtons In varArray
    If Not varButtons.Enabled Then
    varButtons.Enabled = True
    End If
    Next varButtons

    Set cmd2 = Nothing
    Set cmd3 = Nothing
    Set cmd4 = Nothing
    Set cmd5 = Nothing
    Set cmd6 = Nothing

    End Sub

    --
    Kevin Backmann


    "Mike" wrote:

    > Hi Kevin thanks for reply, I have 10 buttons labelled £1, £2 £3 and so on
    > and then 8 buttons i need to make sure one of the 10 (£)buttons has been
    > pressed before any of the 8 buttons, hope that makes sense
    >
    > "Kevin B" wrote:
    >
    > > You can set the enabled property of the second command button to false and in
    > > the code module for the first command button you can use this to activate the
    > > button:
    > >
    > > Private Sub CommandButton1_Click()
    > >
    > > If Not Me.CommandButton2.Enabled Then
    > > Me.CommandButton2.Enabled = True
    > > End If
    > >
    > > End Sub
    > >
    > > --
    > > Kevin Backmann
    > >
    > >
    > > "Mike" wrote:
    > >
    > > > Hi In my worksheet i have 2 sets of buttons, is there a way of preventing
    > > > one set of buttons being used until one of the other set has been pressed
    > > > first, maybe a warning message


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1