By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,519 Members | 2,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,519 IT Pros & Developers. It's quick & easy.

Select all/none

P: n/a
In this single-user app I have a form with members. In the related table I
have a field 'Select' with which the user can select a record. I have two
buttons on the form (All and None) that select either all records or none.
Those buttons both work with an edit query. It works except for the current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by Select=-1 (or
0). It works but the only annoying thing is that after the query Access
shows a dialog box "Info has been changed" with an OK button. What can I do
to avoid this button?
thanks,
john
Sep 7 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi John,

You need to insert this code, you only really need one button.

If you call that button 'btnToggle' and your list box 'lstSelection'
this code should work seamlessly when you insert it in the on click
event of your button.

Dim intSelected As Integer
Dim blnToggle As Boolean
If Me.btnToggle.Caption = "&Select all" Then
blnToggle = True
Me.btnToggle.Caption = "De&select all"
Else
blnToggle = False
Me.btnToggle.Caption = "&Select all"
End If
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
Next
End With

Good luck

Nick

john wrote:
In this single-user app I have a form with members. In the related table I
have a field 'Select' with which the user can select a record. I have two
buttons on the form (All and None) that select either all records or none.
Those buttons both work with an edit query. It works except for the current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by Select=-1 (or
0). It works but the only annoying thing is that after the query Access
shows a dialog box "Info has been changed" with an OK button. What can I do
to avoid this button?
thanks,
john
Sep 7 '06 #2

P: n/a
Oh I forgot to mention that you no longer need the edit query.

Best wishes

Nick

Nick 'The database Guy' wrote:
Hi John,

You need to insert this code, you only really need one button.

If you call that button 'btnToggle' and your list box 'lstSelection'
this code should work seamlessly when you insert it in the on click
event of your button.

Dim intSelected As Integer
Dim blnToggle As Boolean
If Me.btnToggle.Caption = "&Select all" Then
blnToggle = True
Me.btnToggle.Caption = "De&select all"
Else
blnToggle = False
Me.btnToggle.Caption = "&Select all"
End If
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
Next
End With

Good luck

Nick

john wrote:
In this single-user app I have a form with members. In the related table I
have a field 'Select' with which the user can select a record. I have two
buttons on the form (All and None) that select either all records or none.
Those buttons both work with an edit query. It works except for the current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by Select=-1 (or
0). It works but the only annoying thing is that after the query Access
shows a dialog box "Info has been changed" with an OK button. What can I do
to avoid this button?
thanks,
john
Sep 7 '06 #3

P: n/a
Thanks Nick,
The first part is working but I still have trouble with:
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
It doesn't do what it's supposed to. I get an error on .Listcount. Is that
the correct code?

Let me add that in this form only one record of the underlying table is
visible on the form. So there's only one checkbox visible, but i want them
to be (un)checked by pushing the button.
john

"Nick 'The database Guy'" <ni***********@eads.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi John,

You need to insert this code, you only really need one button.

If you call that button 'btnToggle' and your list box 'lstSelection'
this code should work seamlessly when you insert it in the on click
event of your button.

Dim intSelected As Integer
Dim blnToggle As Boolean
If Me.btnToggle.Caption = "&Select all" Then
blnToggle = True
Me.btnToggle.Caption = "De&select all"
Else
blnToggle = False
Me.btnToggle.Caption = "&Select all"
End If
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
Next
End With

Good luck

Nick

john wrote:
>In this single-user app I have a form with members. In the related table
I
have a field 'Select' with which the user can select a record. I have two
buttons on the form (All and None) that select either all records or
none.
Those buttons both work with an edit query. It works except for the
current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by Select=-1
(or
0). It works but the only annoying thing is that after the query Access
shows a dialog box "Info has been changed" with an OK button. What can I
do
to avoid this button?
thanks,
john

Sep 7 '06 #4

P: n/a
I am using access 2003, and if you are using that it 'should' work.
Maybe try seeing what method are exsposed within me.lstSelection. I am
presuming that lstSelection is in actual fact a list box, rather than a
combo box?

Good luck,

Nick
john wrote:
Thanks Nick,
The first part is working but I still have trouble with:
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
It doesn't do what it's supposed to. I get an error on .Listcount. Is that
the correct code?

Let me add that in this form only one record of the underlying table is
visible on the form. So there's only one checkbox visible, but i want them
to be (un)checked by pushing the button.
john

"Nick 'The database Guy'" <ni***********@eads.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi John,

You need to insert this code, you only really need one button.

If you call that button 'btnToggle' and your list box 'lstSelection'
this code should work seamlessly when you insert it in the on click
event of your button.

Dim intSelected As Integer
Dim blnToggle As Boolean
If Me.btnToggle.Caption = "&Select all" Then
blnToggle = True
Me.btnToggle.Caption = "De&select all"
Else
blnToggle = False
Me.btnToggle.Caption = "&Select all"
End If
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
Next
End With

Good luck

Nick

john wrote:
In this single-user app I have a form with members. In the related table
I
have a field 'Select' with which the user can select a record. I have two
buttons on the form (All and None) that select either all records or
none.
Those buttons both work with an edit query. It works except for the
current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by Select=-1
(or
0). It works but the only annoying thing is that after the query Access
shows a dialog box "Info has been changed" with an OK button. What can I
do
to avoid this button?
thanks,
john
Sep 8 '06 #5

P: n/a
lstSelection in fact is a checkboxfield. The underlying tablefield is a
Yes/No field. That's probably why the .listcount gives an error.
lstSelection doens't have methods in itself.
john

"Nick 'The database Guy'" <ni***********@eads.comschreef in bericht
news:11*********************@e3g2000cwe.googlegrou ps.com...
>I am using access 2003, and if you are using that it 'should' work.
Maybe try seeing what method are exsposed within me.lstSelection. I am
presuming that lstSelection is in actual fact a list box, rather than a
combo box?

Good luck,

Nick
john wrote:
>Thanks Nick,
The first part is working but I still have trouble with:
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
It doesn't do what it's supposed to. I get an error on .Listcount. Is
that
the correct code?

Let me add that in this form only one record of the underlying table is
visible on the form. So there's only one checkbox visible, but i want
them
to be (un)checked by pushing the button.
john

"Nick 'The database Guy'" <ni***********@eads.comschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi John,

You need to insert this code, you only really need one button.

If you call that button 'btnToggle' and your list box 'lstSelection'
this code should work seamlessly when you insert it in the on click
event of your button.

Dim intSelected As Integer
Dim blnToggle As Boolean
If Me.btnToggle.Caption = "&Select all" Then
blnToggle = True
Me.btnToggle.Caption = "De&select all"
Else
blnToggle = False
Me.btnToggle.Caption = "&Select all"
End If
With Me.lstSelection
For intSelected = 0 To .ListCount - 1
.selected(intSelected) = blnToggle
Next
End With

Good luck

Nick

john wrote:
In this single-user app I have a form with members. In the related
table
I
have a field 'Select' with which the user can select a record. I have
two
buttons on the form (All and None) that select either all records or
none.
Those buttons both work with an edit query. It works except for the
current
record since that is locked. To avoid that I have added code that
specifically changes the Select value of the current record by
Select=-1
(or
0). It works but the only annoying thing is that after the query
Access
shows a dialog box "Info has been changed" with an OK button. What can
I
do
to avoid this button?
thanks,
john

Sep 8 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.