467,144 Members | 1,164 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

Count Unbound Text Field?

I've looked, and not found much. I have a text field in a form named [myLocation], which acquires its data through a control source of =getLocation()

the getLocation() function returns a DLookup, which changes based on some other field of that record.

Now, I would like the form footer to count the two different locations that may occur. So, naturally I tried:

=Count(IIf([myLocation]="Home",0))

This not only returns #Error on that field, but every other (otherwise working) counting field in the footer. Same thing happens even if I just count([myLocation]). Clearly there's something that I wasn't told. I half-expect a group of my techie friends to pop out of somewhere laughing at me cuz they purposely removed a page from my reference book or something. Any help is greatly appreciated.


Oh and a secondary issue: is there some easy way to count unique field values in a filtered form whose filtered criteria is constantly being changed from the form? (I expect the answer is "no, there is no easy way" - that's fine, just need to know).

All help is always apreciated.
Mar 21 '08 #1
  • viewed: 2937
Share:
3 Replies
JConsulting
Expert 512MB
I've looked, and not found much. I have a text field in a form named [myLocation], which acquires its data through a control source of =getLocation()

the getLocation() function returns a DLookup, which changes based on some other field of that record.

Now, I would like the form footer to count the two different locations that may occur. So, naturally I tried:

=Count(IIf([myLocation]="Home",0))

This not only returns #Error on that field, but every other (otherwise working) counting field in the footer. Same thing happens even if I just count([myLocation]). Clearly there's something that I wasn't told. I half-expect a group of my techie friends to pop out of somewhere laughing at me cuz they purposely removed a page from my reference book or something. Any help is greatly appreciated.


Oh and a secondary issue: is there some easy way to count unique field values in a filtered form whose filtered criteria is constantly being changed from the form? (I expect the answer is "no, there is no easy way" - that's fine, just need to know).

All help is always apreciated.
Your question isn't really clear. Are there more than one fields that you're counting?

You can try using your form's On_Current event to put a value in your count field

If me.MyTextbox = 'somevalue' Then me.MyFooterTextbox = 1

also, wouldn't your syntax be a bit different with the IIF function anyway?

=IIf([mytextbox]="Home",1,0)

But again, if you have a single view form, wouldn't your count always be 1 or 0?
Mar 23 '08 #2
My appologies for the lack of clarity. I'm using a continuous form, with multiple records being displayed at any given time. Furthermore, the records displayed do not change with a query, but by the Me.Filter and vba. The user will be readily changing the filter, and displaying different items frequently. As such, i was hoping for a running tally of certain records. Specifically, a sum or count of a field, whose value is generated from a vba function.

Help? =(
Mar 26 '08 #3
JConsulting
Expert 512MB
My appologies for the lack of clarity. I'm using a continuous form, with multiple records being displayed at any given time. Furthermore, the records displayed do not change with a query, but by the Me.Filter and vba. The user will be readily changing the filter, and displaying different items frequently. As such, i was hoping for a running tally of certain records. Specifically, a sum or count of a field, whose value is generated from a vba function.

Help? =(

since this is already VBA, and you apply a filter using some mechanism, why don't you continue to use VBA and capture the filter being applied, and use that as a criteria agains the recordset in a dcount to populate your count field.
Mar 30 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Stephan | last post: by
4 posts views Thread by Rick Thiel | last post: by
3 posts views Thread by Dos Lil | last post: by
2 posts views Thread by Dave Griffiths | last post: by
10 posts views Thread by Matthew Wells | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.