I have a button on my form that selects all clients in a list box. It
works in the sense that when I click it, it does select all clients.
The problem I'm running into is that when I first open the form the
button defaults to 'Unselect All Clients' when it should default to
'Select All Clients.' Those are the two states of the button. Ideally
I want to open the form and the button reads 'Select All Clients.'
My code:
Private Sub btnselectallcli_Click()
On Error GoTo Err_btnselectallcli_Click
Dim i As Integer
If btnselectallcli.Caption = "Select All Clients" Then
For i = 0 To listclient.ListCount - 1
listclient.Selected(i) = True
Next i
btnselectallcli.Caption = "Unselect All Clients"
Else
For i = 0 To listclient.ListCount - 1
listclient.Selected(i) = False
Next i
btnselectallcli.Caption = "Select All Clients"
End If
Exit_btnselectallcli_Click:
Exit Sub
Err_btnselectallcli_Click:
MsgBox Err.Description
Resume Exit_btnselectallcli_Click
End Sub
....thanks for all the help the group has given me!
Mark
Klatuu - 15 Sep 2006 18:15 GMT
Check the Caption property of the button in design view.
> I have a button on my form that selects all clients in a list box. It
> works in the sense that when I click it, it does select all clients.
[quoted text clipped - 33 lines]
>
> Mark
gambit32 - 15 Sep 2006 18:30 GMT
You had it right. Wow. How simple. Thanks for the quick fix and
response.
> Check the Caption property of the button in design view.
>
[quoted text clipped - 35 lines]
> >
> > Mark
Douglas J. Steele - 15 Sep 2006 18:15 GMT
Call btnselectallcli_Click in your form's Load event (after first making
sure that the caption is what you want):
Private Sub Form_Load()
Me.btnselectallcli.Caption = "Select All Clients"
Call btnselectallcli_Click()
End Sub

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
>I have a button on my form that selects all clients in a list box. It
> works in the sense that when I click it, it does select all clients.
[quoted text clipped - 33 lines]
>
> Mark