?
Solved

Type mismatch error on report

Posted on 2013-01-17
15
Medium Priority
?
465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 668 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 51

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 48

Assisted Solution

by:Dale Fye
Dale Fye earned 664 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 668 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 48

Expert Comment

by:Dale Fye
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 51

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 51

Expert Comment

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

/gustav
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

771 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