Automatic calculation of no. of records

Mute

Registered User.
Local time
Today, 03:44
Joined
Aug 9, 2004
Messages
34
Hey,

I need to know how to set a textbox to automatically input a value into itself.

I have a subdatasheet in my form and want to be able to but into the textbox the no of records in my subdatasheet.

It sounds really simple and it probably is but i am not that experienced with Access so am having problems.

Hope sumone out there can help me :(

Thanx


PS, if u wudnt mind cud u also hav a quick look at my othere threads as im not having much luck with them. thanx. ;)
 
Doesn't the subdatasheet have record navigation bars which will display the record number your on and how many records there are. Would this suffice?
 
It does hav this but I need a field which would "at a glance" tell me the number as it is vital information.

Would me.count do?
 
A textbox on the relevant form with it's ControlSource set to:

=Count([MyField])

Replace MyField with the name of a field in your (sub)form's underlying recordset.
 
Rich said:
or just =Count(*)

I know you can use the wildcard in this instance but I prefer to be explicit when I use this function and name a field; typically the primary key.

I've not tested to see if there's a considerable time difference but I'll look into it when I get a chance. :)
 
Ive dun this:

Private Sub NoOfBoilers_BeforeUpdate(Cancel As Integer)
NoOfBoilers = Me.Count
End Sub

it seems to work
 
As has already been said, put the expression =Count([MyField]) in the ControlSource of NoOfBoilers.

If, as you said, you don't know what you're doing then taking the advice given rather than blundering into the BeforeUpdate event should be the best step forward. :)
 
Sorry if it seemed like i was ignoring ur suggestion.

I need the number of boilers to be saved in the record as a field, will this b possible with what u suggested?
 
Sorry, ive tried as u sed but i get "#Error" in stead of a nuber in the textbox???

What am i doin wrong?
 
Mute said:
I need the number of boilers to be saved in the record as a field,


Why? queries and calculated controls will return the number of records
 
Basically i need to show how many boilers are at a site.

The subdatasheet records each boiler's details.

I dont really mind how it is dun as long as i can store this number.

what was suggestd by SJ McAbny didnt work so im thinking i did sumfing wrong.

i hope u can sort this out for me as its driving me mad now :eek:
 
Mute,

I think the problem could be that you've used the me.count or whatever on the parent form. This will only work as a text box in the subform. You should have a text box in the subform with an afterupdate function that copies it's value into a certain textbox on the parent form. If you still have trouble post your database, obviously without the data and I will have a look and I'm sure others on here will.

Scott
 
I tried to post my database but it is too big an attachment
can i email it to you?

or anyone who can help for that matter!
 

Users who are viewing this thread

Back
Top Bottom