Change button caption on each click

  • Follow


How to change button caption from "Check All" to "Check None" when
clicked, and change back when click again (toggle)? Because of space
limitation, I don't want to create 2 separate buttons.

When click Check All, I update the field to -1
When click Check None, I update the field to 0

Thanks
0
Reply Song 3/23/2010 12:12:31 AM

Something like this in the button's click event.

With Me.cmdBtnName
    If .Caption = "Check All" Then
        .Caption = "Check None"
    ElseIf .Caption = "Check None" Then
        .Caption = "Check All"
    End If
End With

Note: replace cmdBtnName with the name for your button.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Song" <song.usa@gmail.com> wrote in message 
news:53b5d966-cfe7-4c8b-98da-090b572fe018@k6g2000prg.googlegroups.com...
> How to change button caption from "Check All" to "Check None" when
> clicked, and change back when click again (toggle)? Because of space
> limitation, I don't want to create 2 separate buttons.
>
> When click Check All, I update the field to -1
> When click Check None, I update the field to 0
>
> Thanks 


0
Reply Jeanette 3/23/2010 2:05:49 AM


On Mar 22, 7:05=A0pm, "Jeanette Cunningham"
<n...@discussions.microsoft.com> wrote:
> Something like this in the button's click event.
>
> With Me.cmdBtnName
> =A0 =A0 If .Caption =3D "Check All" Then
> =A0 =A0 =A0 =A0 .Caption =3D "Check None"
> =A0 =A0 ElseIf .Caption =3D "Check None" Then
> =A0 =A0 =A0 =A0 .Caption =3D "Check All"
> =A0 =A0 End If
> End With
>
> Note: replace cmdBtnName with the name for your button.
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
> "Song" <song....@gmail.com> wrote in message
>
> news:53b5d966-cfe7-4c8b-98da-090b572fe018@k6g2000prg.googlegroups.com...
>
>
>
> > How to change button caption from "Check All" to "Check None" when
> > clicked, and change back when click again (toggle)? Because of space
> > limitation, I don't want to create 2 separate buttons.
>
> > When click Check All, I update the field to -1
> > When click Check None, I update the field to 0
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -

Thank you, Jeanette. Under what event should I put the code? After
each click, I use docmd.runsql to replace all.
0
Reply Song 3/23/2010 1:15:46 PM

Or (assuming the field is Boolean):

Private Sub cmdBtnName_Click()
  field = Not field
  cmdBtnName.Caption = Switch(field, "Check None", Not field, "Check All")
End Sub

Jon



"Jeanette Cunningham" <nnn@discussions.microsoft.com> wrote in message 
news:eH5%23i3iyKHA.244@TK2MSFTNGP06.phx.gbl...
> Something like this in the button's click event.
>
> With Me.cmdBtnName
>    If .Caption = "Check All" Then
>        .Caption = "Check None"
>    ElseIf .Caption = "Check None" Then
>        .Caption = "Check All"
>    End If
> End With
>
> Note: replace cmdBtnName with the name for your button.
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
> "Song" <song.usa@gmail.com> wrote in message 
> news:53b5d966-cfe7-4c8b-98da-090b572fe018@k6g2000prg.googlegroups.com...
>> How to change button caption from "Check All" to "Check None" when
>> clicked, and change back when click again (toggle)? Because of space
>> limitation, I don't want to create 2 separate buttons.
>>
>> When click Check All, I update the field to -1
>> When click Check None, I update the field to 0
>>
>> Thanks
>
> 


0
Reply Jon 3/23/2010 1:49:06 PM

As I mentioned in the last post, put the code in the on click event for the 
button that runs that query.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Song" <song.usa@gmail.com> wrote in message 
news:c7cfe994-892c-450d-8501-20f537965d40@p3g2000pra.googlegroups.com...
On Mar 22, 7:05 pm, "Jeanette Cunningham"
<n...@discussions.microsoft.com> wrote:
> Something like this in the button's click event.
>
> With Me.cmdBtnName
> If .Caption = "Check All" Then
> .Caption = "Check None"
> ElseIf .Caption = "Check None" Then
> .Caption = "Check All"
> End If
> End With
>
> Note: replace cmdBtnName with the name for your button.
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
> "Song" <song....@gmail.com> wrote in message
>
> news:53b5d966-cfe7-4c8b-98da-090b572fe018@k6g2000prg.googlegroups.com...
>
>
>
> > How to change button caption from "Check All" to "Check None" when
> > clicked, and change back when click again (toggle)? Because of space
> > limitation, I don't want to create 2 separate buttons.
>
> > When click Check All, I update the field to -1
> > When click Check None, I update the field to 0
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -

Thank you, Jeanette. Under what event should I put the code? After
each click, I use docmd.runsql to replace all. 


0
Reply Jeanette 3/24/2010 9:54:52 AM

4 Replies
966 Views

(page loaded in 0.066 seconds)

Similiar Articles:
















7/24/2012 2:00:34 AM


Reply: