Count Field (?)

Dimitris

Registered User.
Local time
Today, 04:19
Joined
Dec 8, 2008
Messages
12
Hi everybody,

i have a (Continuous) form that gives me some loading details like:
Date, Type of Vehicle, Number of Vehicles, Destination, Weight....etc etc.
I have 2 Types of Vehicle. TYPE A and TYPE B.
In the Form footer i get the sums i need and also the sum of Vehicles but for both Types.
I need a field for TYPE A=(whatever result)
a Field for TYPE B=(whatever result)
how can i get this? is there some kind of count command.

Your help will be much apreciated/ needed.

tks in advance
Dimitri
 

many tks Rainman but this is returning back the number of records.that would work great if i had 1 vehicle per each record.
But i have the following:
example:for 1 record with type A (type of vehicle) =3 vehicles
another record with Type B=2 vehicles

if i got it right , Dcount will return back value for Type A=1 while i need to get value=3.

any idea?
 
From what i can tell i think you might need a DSum not DCount.
 
Ah yea.. I thought each record had one vehicle. Not 1 record had 3 or more (or less). Dsum would work
 
Sorry for late reply. I'll try with dsum.

tks for helping
D.
 
=Sum(Iif([FieldType]=A,3,0))
=Sum(Iif([FieldType]=B,2,0))
 
you have to do this manually, for each type I think, to have the totals in the subform

you are really looking for a continous summary, of a continuous form - in YOUR case you only have 2 vehicle types, but this is really a special case of any normal table with many types.

eg in your case, what if you decide you need MORE than two types of vehicles,

so 2 alternatives, which dont need any textboxes hard coding with dcount stuff, (although they will still need some VBA coding)

1.
an EASIER way is to give the users a filter (option group or combo box) offering "A" vehicles, "B" Vehicles, or All vehicles - then they just see 3,2, or 5 depending on what they click. - and it is easy to add another vehicle type "C" in due course.

2
OR you could have ANOTHER continuous subform, just showing the vehicle group totals, which would deal with additional vehicle types automatically.
 
i have only 2 type of vehicles but their values are not only 2 and 3.
sorry if i coused confusion by the way i explained but i just gave these figures as an example.
the IIF cmnd will return only values 2 or or 0 (isn't ???).
Filter also is not the needed solution since i need to see both results in form footer (at the same time).
 
i dont think so - i think rich's expressions may need changing slightly - try these

=Sum(Iif([FieldType]="A",1,0))
=Sum(Iif([FieldType]="B",1,0))

or even try these
=dcount("*",me.recordsource,"[fieldtype] = "A")
=dcount("*",me.recordsource,"[fieldtype] = "B")
 

Users who are viewing this thread

Back
Top Bottom