On Current event

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

Guest

I have a subform on which I would to do a record count. Vendor_Count is an
unbound field on the subform where I would like to store the count. I tried
putting the following code on the On Current event of the subform:

Vendor_Count=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] =
'Active' and [Peer_Group_Code] <> 11 ")

It isn't working - it's counting ALL records retrieved by the
qry_Zip_Code_Vendors (which is the source of the subform). I would like a
count of the records fitting the criteria above for the records currently
displayed. How can I do this?

Thanks!
 
Does your DCount() understand "the records currently displayed"? There is
nothing dynamic in the expression that you are using.

BTW: An unbound field (text box) will not store anything. It will only
display a value.
 
That's where my problem lies - I thought by putting the code in the On
Current that it would apply to the records currently displayed. As I found
out, it doesn't. :-)

I thought it would work because I have the following code in my On Current
Event and it correctly recalculates as I click through my records on the form:

If Urban_Rural_Code = "U" Then Vendor_Participant_Ratio =
[Participant_Count] / 175.

Do you have any idea how I can make my count work? BTW - I don't need to
store the value, just display it on the fly.

Thanks!

Duane Hookom said:
Does your DCount() understand "the records currently displayed"? There is
nothing dynamic in the expression that you are using.

BTW: An unbound field (text box) will not store anything. It will only
display a value.

--
Duane Hookom
MS Access MVP
--

Lori said:
I have a subform on which I would to do a record count. Vendor_Count is an
unbound field on the subform where I would like to store the count. I
tried
putting the following code on the On Current event of the subform:

Vendor_Count=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] =
'Active' and [Peer_Group_Code] <> 11 ")

It isn't working - it's counting ALL records retrieved by the
qry_Zip_Code_Vendors (which is the source of the subform). I would like a
count of the records fitting the criteria above for the records currently
displayed. How can I do this?

Thanks!
 
You must have some value on your form that would further filter your:
Vendor_Count=DCount("...","...","[Status_Code] = 'Active' and
[Peer_Group_Code] <> 11 ")

--
Duane Hookom
MS Access MVP
--

Lori said:
That's where my problem lies - I thought by putting the code in the On
Current that it would apply to the records currently displayed. As I
found
out, it doesn't. :-)

I thought it would work because I have the following code in my On Current
Event and it correctly recalculates as I click through my records on the
form:

If Urban_Rural_Code = "U" Then Vendor_Participant_Ratio =
[Participant_Count] / 175.

Do you have any idea how I can make my count work? BTW - I don't need to
store the value, just display it on the fly.

Thanks!

Duane Hookom said:
Does your DCount() understand "the records currently displayed"? There is
nothing dynamic in the expression that you are using.

BTW: An unbound field (text box) will not store anything. It will only
display a value.

--
Duane Hookom
MS Access MVP
--

Lori said:
I have a subform on which I would to do a record count. Vendor_Count is
an
unbound field on the subform where I would like to store the count. I
tried
putting the following code on the On Current event of the subform:

Vendor_Count=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code]
=
'Active' and [Peer_Group_Code] <> 11 ")

It isn't working - it's counting ALL records retrieved by the
qry_Zip_Code_Vendors (which is the source of the subform). I would
like a
count of the records fitting the criteria above for the records
currently
displayed. How can I do this?

Thanks!
 

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

Similar Threads

On Current event 5
Record Count 1
Criteria 4
Help! - calculated control 6
Count code 3
Access Dcount (multiple criteria) 3
Recordcount is always 1 step behind. 1
DCount in Subform question 1

Back
Top