Selection Count

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with list of names. The form consist of a true/false field used
for selection and a name field. And a selection counter box use to show the
number of name selector. I coded the selection box
=DCount("[MergeLetter]","qrySelectCounter"). The qrySelectCount sums the
number of true selection.

The problem is that the Selection Counter Box is not update every time a new
selection is made. I only update when the form opens.

Help greatly appreciated.
Thank You

Ileana
 
Ileana,

It sounds like you are talking about a continuous form with a text box in
the footer that tells how many items are checked. If this is the case, you
can put some code in the Click event of the checkbox that will requery the
textbox control. It would look something like:

Private Sub chk_Selected_Click()

me.txt_Selected_Count.requery

End Sub

HTH
 
Thank very much. This works, but one small problem. The count is off by one.
Example; If 3 selected. the count displays 2.

I try using docmd.Save , before the requery code.

Dale Fye said:
Ileana,

It sounds like you are talking about a continuous form with a text box in
the footer that tells how many items are checked. If this is the case, you
can put some code in the Click event of the checkbox that will requery the
textbox control. It would look something like:

Private Sub chk_Selected_Click()

me.txt_Selected_Count.requery

End Sub

HTH


--
Email address is not valid.
Please reply to newsgroup only.


iholder said:
I have a form with list of names. The form consist of a true/false field used
for selection and a name field. And a selection counter box use to show the
number of name selector. I coded the selection box
=DCount("[MergeLetter]","qrySelectCounter"). The qrySelectCount sums the
number of true selection.

The problem is that the Selection Counter Box is not update every time a new
selection is made. I only update when the form opens.

Help greatly appreciated.
Thank You

Ileana
 
Thank very much. This works, but one small problem. The count is off by one.
Example; If 3 selected. the count displays 2.

I try using docmd.Save , before the requery code.

Dale Fye said:
Ileana,

It sounds like you are talking about a continuous form with a text box in
the footer that tells how many items are checked. If this is the case, you
can put some code in the Click event of the checkbox that will requery the
textbox control. It would look something like:

Private Sub chk_Selected_Click()

me.txt_Selected_Count.requery

End Sub

HTH

--
Email address is not valid.
Please reply to newsgroup only.

iholder said:
I have a form with list of names. The form consist of a true/false field used
for selection and a name field. And a selection counter box use to show the
number of name selector. I coded the selection box
=DCount("[MergeLetter]","qrySelectCounter"). The qrySelectCount sums the
number of true selection.

The problem is that the Selection Counter Box is not update every time a new
selection is made. I only update when the form opens.

Help greatly appreciated.
Thank You

Ileana

1) Your DCount expression will count ALL the records in the query, not
just those where the check box field is true, unless the query itself
is filtering out the false records.
Use:
=DCount("*","qrySelectCounter","[CheckBoxFieldName] = True")
to count just the checked boxes.

2) Code the Check Box AfterUpdate event:
Me.Refresh
to update the count each time the check box is checked or un-checked.

3) docmd.Save saves changes made to the form design, not the new
records.
Use:
Docmd.RunCommand acCmdSaveRecord
to save new records (However, in this case you don't need to.).
 
Thank you very much.

My problems are all resolved.

Ileana
fredg said:
Thank very much. This works, but one small problem. The count is off by one.
Example; If 3 selected. the count displays 2.

I try using docmd.Save , before the requery code.

Dale Fye said:
Ileana,

It sounds like you are talking about a continuous form with a text box in
the footer that tells how many items are checked. If this is the case, you
can put some code in the Click event of the checkbox that will requery the
textbox control. It would look something like:

Private Sub chk_Selected_Click()

me.txt_Selected_Count.requery

End Sub

HTH

--
Email address is not valid.
Please reply to newsgroup only.

:

I have a form with list of names. The form consist of a true/false field used
for selection and a name field. And a selection counter box use to show the
number of name selector. I coded the selection box
=DCount("[MergeLetter]","qrySelectCounter"). The qrySelectCount sums the
number of true selection.

The problem is that the Selection Counter Box is not update every time a new
selection is made. I only update when the form opens.

Help greatly appreciated.
Thank You

Ileana

1) Your DCount expression will count ALL the records in the query, not
just those where the check box field is true, unless the query itself
is filtering out the false records.
Use:
=DCount("*","qrySelectCounter","[CheckBoxFieldName] = True")
to count just the checked boxes.

2) Code the Check Box AfterUpdate event:
Me.Refresh
to update the count each time the check box is checked or un-checked.

3) docmd.Save saves changes made to the form design, not the new
records.
Use:
Docmd.RunCommand acCmdSaveRecord
to save new records (However, in this case you don't need to.).
 
Back
Top