Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Type mismatch error on report

Posted on 2013-01-17
15
Medium Priority
?
467 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 52

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
Technology Partners: 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!

 
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 52

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 52

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 52

Expert Comment

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

/gustav
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

618 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