Solved

Type mismatch error on report

Posted on 2013-01-17
15
461 Views
Last Modified: 2013-01-18
I have a report which has two sub-reports.  In the detail section of the main report I have a calculated field which is...

=[subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood]+Abs([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods])-[Order_Qty]

Obviously the field gets its calculation from the two sub-reports.

But if [subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood] has no value then I get the error: "Type mismatch" when I run the report.  I've tried...

=Nz([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood],0)+Nz(Abs([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods])-[Order_Qty],0)

but that didn't work.  I've also tried the Nz "thing in the subreport fields but that didn't work.  

Incidently, the "Abs" in "Abs([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods])" is there because the real number is a negative value and I need to turn it into a positive value for the report.

Thoughts?
0
Comment
Question by:SteveL13
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 167 total points
ID: 38788132
You can try with:

=[subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood]-[subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods]-[Order_Qty]

/gustav
0
 

Author Comment

by:SteveL13
ID: 38788151
Still get type mismatch.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38788168
= NZ([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood],0) + Abs(NZ([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods]),0) - NZ([Order_Qty],0))

Open in new window


The NZs should go inside your ABS function.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 61

Expert Comment

by:mbizup
ID: 38788177
Correction:

= NZ([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood],0) + Abs(NZ([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods],0)) - NZ([Order_Qty],0)

Open in new window

0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 38788180
Perhaps counting records:

=IIf(Count([subrptOrdHistReportFINISHEDGOOD].[Report])=0,Null,[subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood]-[subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods]-[Order_Qty])

/gustav
0
 

Author Comment

by:SteveL13
ID: 38788186
Getting wrong number of arguments with:

= NZ([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood],0) + Abs(NZ([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods],0)) - NZ([Order_Qty],0)
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 166 total points
ID: 38788188
You might find this surprising, but if you are using the NZ( ) method in a query, the results will be a text string, so what I do, in the query is:

Val(NZ([somefield], 0))

If you run a query where on a table where you know you have some NULL values, you can experiment with the optional ValueIfNull argument, but you can provide dates, or numbers and the result will always be left justified (string) rather than the proper data type.

For that reason, I always explicitly convert the result of the NZ function back to the appropriate data type

Val(NZ([somefield],0))
cint(NZ([somefield], 0))
cdate(NZ([datefield], #1/1/12#))
0
 
LVL 61

Accepted Solution

by:
mbizup earned 167 total points
ID: 38788198
Hmm...
Give this another try.

The syntax seems okay in the VBA Editor:

= Nz([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood], 0) + Abs(Nz([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods], 0)) - Nz([Order_Qty], 0)

Open in new window

0
 

Author Comment

by:SteveL13
ID: 38788222
I tried:

Me.txtExcess = Nz([subrptOrdHistReportFINISHEDGOOD].[Report]![txtTotGood], 0) + Abs(Nz([subrptOrdHistReportFINGOODS].[Report]![txtTotFinGoods], 0)) - Nz([Order_Qty], 0)

in the onprint event of the detail and get "you entered an expression that has no value"
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38788269
so, this textbox is on the Detail section of the report, and you are trying to refer to these values on your subreport?
0
 

Author Comment

by:SteveL13
ID: 38788279
So now I'm trying to narrow this down.  I setup another field in the detail section and in VBA code entered:

Me.txtFinGoodQty = CInt(Nz([subrptOrdHistReportFINISHEDGOOD].[Report]![txtQtyGood], 0))

and also tried

Me.txtFinGoodQty = Val(Nz([subrptOrdHistReportFINISHEDGOOD].[Report]![txtQtyGood], 0))

and removed the control source from the property sheet of the fields in the detail.

Now get "You entered an expression that has no value" error.  When I hover over the "me.txtFinGoodQty" I see "Me.txtFinGoodQty = Null"

??
0
 

Author Comment

by:SteveL13
ID: 38788282
Regarding:

so, this textbox is on the Detail section of the report, and you are trying to refer to these values on your subreport?

Yes.  That is correct.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 38788295
So you couldn't count records?

/gustav
0
 

Author Comment

by:SteveL13
ID: 38789716
Well, I guess I feel really stupid.  The problem was my own.  I was looking at a wrong field for data in the formula to begin with. The best I can do I think is split the points to all that tried to help.  I am truly very sorry for the confusion.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 38792390
OK, that explains.

/gustav
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question