Count Yes/No Field = True

B

bw

Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain how to
count only when values of eBay are True?

Thanks,
Bernie
 
B

bw

Thanks Pat,
I appreciate your help.
Bernie

Pat Hartman said:
Expr1: DCount("[eBay]","tblParts","[eBay] = True"
bw said:
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain how to
count only when values of eBay are True?

Thanks,
Bernie
 
B

bw

Now that the calculation is correct, the Form is not updating when I click
on the Yes/No field. If I exit and return to the Form, then the field is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No field =
"Yes"?

Thanks again,
Bernie


Pat Hartman said:
Expr1: DCount("[eBay]","tblParts","[eBay] = True"
bw said:
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain how to
count only when values of eBay are True?

Thanks,
Bernie
 
R

Rob Parker

Add the following code to the AfterUpdate event of the Ebay control:

Private Sub chkEbay_AfterUpdate()
Recalc
End Sub

If you enter the code via the ... at the end of the After Update line in the
Events tab of the control's property box, the "Private Sub ... " and "End
Sub" lines will be present, with the correct name of your control (shown as
chkEbay in the sample above).

HTH,

Rob

bw said:
Now that the calculation is correct, the Form is not updating when I click
on the Yes/No field. If I exit and return to the Form, then the field is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No field =
"Yes"?

Thanks again,
Bernie


Pat Hartman said:
Expr1: DCount("[eBay]","tblParts","[eBay] = True"
bw said:
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain
how
to
count only when values of eBay are True?

Thanks,
Bernie
 
B

bw

Thanks for responding Rob!

Ok, I'm getting really confused.
I have the following event after getting the original problem to work:

Private Sub chkEbay_AfterUpdate()
Forms!PARTSFORM.Refresh
Forms!PARTSFORM.Repaint
Forms!PARTSFORM.Recalc
Forms!PARTSFORM.Requery
End Sub

As I STEP through this when I change chkEbay, the first three (Refresh,
Repaint,Recalc) do nothing. The last one (Requery) DOES update the
form...but it then immediately goes to the "1st" record. This confuses me
to no end, as a Help on Requery has the following statement: "Note The
Requery action does not affect the position of the record pointer."

But as I said, the record pointer is changed to the first record.
So can anyone help guide me to the correct solution?

Thanks,
Bernie


Rob Parker said:
Add the following code to the AfterUpdate event of the Ebay control:

Private Sub chkEbay_AfterUpdate()
Recalc
End Sub

If you enter the code via the ... at the end of the After Update line in
the
Events tab of the control's property box, the "Private Sub ... " and "End
Sub" lines will be present, with the correct name of your control (shown
as
chkEbay in the sample above).

HTH,

Rob

bw said:
Now that the calculation is correct, the Form is not updating when I
click
on the Yes/No field. If I exit and return to the Form, then the field is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No field =
"Yes"?

Thanks again,
Bernie


Pat Hartman said:
Expr1: DCount("[eBay]","tblParts","[eBay] = True"
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain how
to
count only when values of eBay are True?

Thanks,
Bernie
 
R

Rob Parker

Refresh and Recalc will both work here; you only need one of them. Requery
also forces the form to update, but (as you have found) returns to the first
record in the recordset. That is its standard behaviour.

I've just checked in A97, and I find no reference in the Help on Requery
(either method or action) stating that the record pointer is unaffected.
Note that this code is using the Requery method, not the Requery action -
maybe they're different in other versions and your Help is correct for that
(or, if it's A2K, be wary - it's Help is dreadful (but usually because it's
incomplete, not incorrect)).

I've also stepped through the code you listed, and find it works as I
describe (and expect) . I progressively comment out the lines which update
the form, as once this has occurred (from the Refresh in the first line)
nothing else happens until the form is completely reset (to the first
record) via the Requery.

HTH,

Rob


bw said:
Thanks for responding Rob!

Ok, I'm getting really confused.
I have the following event after getting the original problem to work:

Private Sub chkEbay_AfterUpdate()
Forms!PARTSFORM.Refresh
Forms!PARTSFORM.Repaint
Forms!PARTSFORM.Recalc
Forms!PARTSFORM.Requery
End Sub

As I STEP through this when I change chkEbay, the first three (Refresh,
Repaint,Recalc) do nothing. The last one (Requery) DOES update the
form...but it then immediately goes to the "1st" record. This confuses me
to no end, as a Help on Requery has the following statement: "Note The
Requery action does not affect the position of the record pointer."

But as I said, the record pointer is changed to the first record.
So can anyone help guide me to the correct solution?

Thanks,
Bernie


Rob Parker said:
Add the following code to the AfterUpdate event of the Ebay control:

Private Sub chkEbay_AfterUpdate()
Recalc
End Sub

If you enter the code via the ... at the end of the After Update line in
the
Events tab of the control's property box, the "Private Sub ... " and "End
Sub" lines will be present, with the correct name of your control (shown
as
chkEbay in the sample above).

HTH,

Rob

bw said:
Now that the calculation is correct, the Form is not updating when I
click
on the Yes/No field. If I exit and return to the Form, then the field is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No field =
"Yes"?

Thanks again,
Bernie


Expr1: DCount("[eBay]","tblParts","[eBay] = True"
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone
explain
how
to
count only when values of eBay are True?

Thanks,
Bernie
 
B

bw

Rob, oh Rob!

I screwed up. I was only "updating" the form with one of your suggestions
if the yes/no box was yes. Yes, I know...what a bozo. Once I discovered
that problem, then I was able to test, and decided that "Recalc" was the
best, as it updated instantaneously, while Refresh had a visible delay on
the form. In any case, it is now working properly.

Thanks for your help, and patience with me.
Bernie


Rob Parker said:
Refresh and Recalc will both work here; you only need one of them.
Requery
also forces the form to update, but (as you have found) returns to the
first
record in the recordset. That is its standard behaviour.

I've just checked in A97, and I find no reference in the Help on Requery
(either method or action) stating that the record pointer is unaffected.
Note that this code is using the Requery method, not the Requery action -
maybe they're different in other versions and your Help is correct for
that
(or, if it's A2K, be wary - it's Help is dreadful (but usually because
it's
incomplete, not incorrect)).

I've also stepped through the code you listed, and find it works as I
describe (and expect) . I progressively comment out the lines which
update
the form, as once this has occurred (from the Refresh in the first line)
nothing else happens until the form is completely reset (to the first
record) via the Requery.

HTH,

Rob


bw said:
Thanks for responding Rob!

Ok, I'm getting really confused.
I have the following event after getting the original problem to work:

Private Sub chkEbay_AfterUpdate()
Forms!PARTSFORM.Refresh
Forms!PARTSFORM.Repaint
Forms!PARTSFORM.Recalc
Forms!PARTSFORM.Requery
End Sub

As I STEP through this when I change chkEbay, the first three (Refresh,
Repaint,Recalc) do nothing. The last one (Requery) DOES update the
form...but it then immediately goes to the "1st" record. This confuses
me
to no end, as a Help on Requery has the following statement: "Note The
Requery action does not affect the position of the record pointer."

But as I said, the record pointer is changed to the first record.
So can anyone help guide me to the correct solution?

Thanks,
Bernie


Rob Parker said:
Add the following code to the AfterUpdate event of the Ebay control:

Private Sub chkEbay_AfterUpdate()
Recalc
End Sub

If you enter the code via the ... at the end of the After Update line
in
the
Events tab of the control's property box, the "Private Sub ... " and "End
Sub" lines will be present, with the correct name of your control
(shown
as
chkEbay in the sample above).

HTH,

Rob

Now that the calculation is correct, the Form is not updating when I
click
on the Yes/No field. If I exit and return to the Form, then the field is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No
field =
"Yes"?

Thanks again,
Bernie


Expr1: DCount("[eBay]","tblParts","[eBay] = True"
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain
how
to
count only when values of eBay are True?

Thanks,
Bernie
 
R

Rob Parker

C'est la vie ;-)

Glad to have helped ...

Rob

bw said:
Rob, oh Rob!

I screwed up. I was only "updating" the form with one of your suggestions
if the yes/no box was yes. Yes, I know...what a bozo. Once I discovered
that problem, then I was able to test, and decided that "Recalc" was the
best, as it updated instantaneously, while Refresh had a visible delay on
the form. In any case, it is now working properly.

Thanks for your help, and patience with me.
Bernie


Rob Parker said:
Refresh and Recalc will both work here; you only need one of them.
Requery
also forces the form to update, but (as you have found) returns to the
first
record in the recordset. That is its standard behaviour.

I've just checked in A97, and I find no reference in the Help on Requery
(either method or action) stating that the record pointer is unaffected.
Note that this code is using the Requery method, not the Requery action -
maybe they're different in other versions and your Help is correct for
that
(or, if it's A2K, be wary - it's Help is dreadful (but usually because
it's
incomplete, not incorrect)).

I've also stepped through the code you listed, and find it works as I
describe (and expect) . I progressively comment out the lines which
update
the form, as once this has occurred (from the Refresh in the first line)
nothing else happens until the form is completely reset (to the first
record) via the Requery.

HTH,

Rob


bw said:
Thanks for responding Rob!

Ok, I'm getting really confused.
I have the following event after getting the original problem to work:

Private Sub chkEbay_AfterUpdate()
Forms!PARTSFORM.Refresh
Forms!PARTSFORM.Repaint
Forms!PARTSFORM.Recalc
Forms!PARTSFORM.Requery
End Sub

As I STEP through this when I change chkEbay, the first three (Refresh,
Repaint,Recalc) do nothing. The last one (Requery) DOES update the
form...but it then immediately goes to the "1st" record. This confuses
me
to no end, as a Help on Requery has the following statement: "Note The
Requery action does not affect the position of the record pointer."

But as I said, the record pointer is changed to the first record.
So can anyone help guide me to the correct solution?

Thanks,
Bernie


"Rob Parker" <CUT_THIS robpparker at optusnet dot com dot au> wrote in
message Add the following code to the AfterUpdate event of the Ebay control:

Private Sub chkEbay_AfterUpdate()
Recalc
End Sub

If you enter the code via the ... at the end of the After Update line
in
the
Events tab of the control's property box, the "Private Sub ... " and "End
Sub" lines will be present, with the correct name of your control
(shown
as
chkEbay in the sample above).

HTH,

Rob

Now that the calculation is correct, the Form is not updating when I
click
on the Yes/No field. If I exit and return to the Form, then the
field
is
updated, but it does not update immediately.

Can you explain how I get it to update whenever I make the Yes/No
field =
"Yes"?

Thanks again,
Bernie


Expr1: DCount("[eBay]","tblParts","[eBay] = True"
Expr1: DCount("[eBay]","tblParts","[eBay] = " & [tblParts]![eBay])
This is the expression I am using, where eBay is a yes/no field.

This is counting all the records in my database. Can someone explain
how
to
count only when values of eBay are True?

Thanks,
Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top