help to add :the values in field

eddii

Registered User.
Local time
Today, 13:32
Joined
Oct 10, 2011
Messages
55
[STATUSCER]
Field name
STATUSCEROKNGCASCRAPPENDINGBREAK DOWNMISSING
i want to add the contents of the above filed which has many texts right now iam using these to add or count

OK_Count: IIf([STATUSCER]="ok",1,0)
ng_Count: IIf([STATUSCER]="ng",1,0)
pending_Count: IIf([STATUSCER]="pending",1,0)
BREAK DOWN_Count: IIf([STATUSCER]="BREAK DOWN",1,0)
MISSING_Count: IIf([STATUSCER]="MISSING",1,0)
blank_count: IIf(IsNull([statuscer]),1,0)

and i give OK_Count in report it shows count

i want this to be done with Vba code how to do this can any one help

because when i export to Excel i do not get the values of this in the excel report
 
I don't completely understand your question but have you considered using a Crosstab query?
i want this to be done with Vba code how to do this can any one help
What about the Count() function?

because when i export to Excel i do not get the values of this in the excel report
What do you mean? Can you explain. If you export the report the totals will show.
 
THANKS vbaInet : Re: help to add :the values in field

THANKS vbaInet :

[STATUSCER] Field name
values in field
OK
NG
CA
SCRAP
PENDING
BREAK DOWN
MISSING

i want to add the contents of the above filed which has many texts right now iam using these to add or count

OK_Count: IIf([STATUSCER]="ok",1,0)
ng_Count: IIf([STATUSCER]="ng",1,0)
pending_Count: IIf([STATUSCER]="pending",1,0)
BREAK DOWN_Count: IIf([STATUSCER]="BREAK DOWN",1,0)
MISSING_Count: IIf([STATUSCER]="MISSING",1,0)
blank_count: IIf(IsNull([statuscer]),1,0)

and i give OK_Count in report it shows count

i want this to be done with Vba code how to do this can any one help

because when i export to Excel i do not get the values of this in the excel report

Actually there is a form which has a button which runs on vba code and a report is opened by it

i have used crosstab query but i dont know to connect that to the report

i have used count function also here is it


OK_Count: IIf([STATUSCER]="ok",1,0)
ng_Count: IIf([STATUSCER]="ng",1,0)
pending_Count: IIf([STATUSCER]="pending",1,0)
BREAK DOWN_Count: IIf([STATUSCER]="BREAK DOWN",1,0)
MISSING_Count: IIf([STATUSCER]="MISSING",1,0)
blank_count: IIf(IsNull([statuscer]),1,0)

i have attached the database in which i have these expressions

query name is monthwise

report name is planmonth

form name reportform

select year = 2011
plant = p1
shop = qd
month= jan

and click calibraiton month status you can see the totals and if you export to excel you will not get the counts

PLS GUIDE ONCE AGAIN
 

Attachments

Did you try DoCmd.OuptutTo with an acFortmatXLS format?

If that doesn't work you will need to replace those textboxes with a subreport that does the count.
 
thanks but i dont know how to write the code

can you tell what change has to be done so that i will update the code


Private Sub Calibration_MonthSTATUS_Click()
Dim strPlantmonth As String
Dim strShopmonth As String
Dim strmonthofcal As String
Dim StrWhere As String

strPlantmonth = GetList1(Me.plantmonth)
strShopmonth = GetList1(Me.shopmonth)
strmonthofcal = GetList1(Me.monthofcal)
If Len(strPlantmonth) Then StrWhere = "PLANT IN " & strPlantmonth
If Len(strShopmonth) Then StrWhere = IIf(Len(StrWhere) > 0, StrWhere & " AND ", "") & "SHOP IN " & strShopmonth
If Len(strmonthofcal) Then StrWhere = IIf(Len(StrWhere) > 0, StrWhere & " AND ", "") & "monthofcal IN " & strmonthofcal
DoCmd.OpenReport "planmonth", acViewPreview, , StrWhere
End Sub
Private Function GetList1(ByVal List As ListBox) As String
Dim strList As String
Dim varItem As Variant

For Each varItem In List.ItemsSelected
If Len(strList) > 0 Then strList = strList & ", "
strList = strList & "'" & List.Column(0, varItem) & "'"
Next varItem
If Len(strList) > 0 Then strList = "(" & strList & ")"
GetList1 = strList

End Function


vbaInet if you can just check, if any thing can be done to this thread

http://www.access-programmers.co.uk/forums/showthread.php?t=219305
 
Last edited:
You will use the Count(IIF()) code I told you about earlier. This will go in a query and this query will be the Record Source of a report. The report will then be a subreport in your main report that replaces those textboxes.
 

Users who are viewing this thread

Back
Top Bottom