How to use the Count function in a navigation form

Damob9K

Trainee numpty
Local time
Today, 13:13
Joined
Apr 12, 2014
Messages
69
Hello all,

I want to be able to use the Count function that will reside in the header of the main navigation form that will count the records in each navigation sub form (of which there are 6 sub forms)

Each sub form has the same primary key which is what I am doing the count on.

I have done this on another form with no subforms by creating a Textbox with this code: =Count([PCNumber])

I have tried to put this in the header of the main navigation form with various itterations, the last being: =Count([Form]![NavigationSubform].[PCNumber])

But what ever I do seems to come up with "Error" in the textbox.

For info, the form names are:

Main form :StockViewsForm
Subform:NavigationSubform

PCNumber being the PK I want to count.

Is this possible of do I need to specify the names of the actual forms that reside in the Navigation Sub Form ??

Many thanks for any help

Damob.

PS. I have referred to the page http://access.mvps.org/access/forms/frm0031.htm but I can't seem to get this to work using those principles
 
Shouldn't it be "Forms" instead of "Form"?
Count([Forms]![NavigationSubform].[PCNumber])
 
Hi JHB, thanks for the speedy response (I was hoping that someone would be active even on a Sunday !!)

Unfortunately that also displays a "#Error" in the textbox ... (I had tried that one before, I think!)

Cheers

D
 
Further thoughts:

I think the issue (and I say this as a Access newbie/numpty) is that the "NavigationSubform" is actually a placeholder for the subforms that are then populated into "NavigationSubform" when the appropriate button is pressed.

But based on all of my recent history of learning Access as I go along, every time I have thought that I have hit a "Access can't do that" issue, I have been proven wrong, so shirley there must be a way of doing this ?

Cheers
Damob
 
Post a stripped version of your database with some sample data, (zip it).
 
OK thanks JHB.

Pretty much removed all forms, tables, queries and reports as they were all tagged with corporate logos, dbase is set to open the nav form in question.

Thanks for taking a look.

BTW I have tried building the function with the expression builder, before anyone asks (or suggests to do that) and it still fails.
I also just added a simple txtfield = navigationsubform.PCNunmer into the txt box and that works fine.

So I am convinced there must be a different way the count function needs to be applied in navigation forms.

Thanks agian

Damob
 

Attachments

The only way it seems to work correct each time is to set the value of textbox in each form's current event.
Database is attached.
 

Attachments

Thanks JHB,

That's spot on !!

As always I learn something new every day :)

It's very strange that the count function works fine in all other form environments but not when used in a navigation form.

I'm really happy that this issue is sorted thanks to you, I can pretty much finish the DB off now, other than working out the best way to import the raw data from a number of spreadsheets , but that's going to have to wait - just done a 11 hour stint at work and can barely focus !!

Thanks a million

Damob
 
You're welcome, luck with your project.
 

Users who are viewing this thread

Back
Top Bottom