Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help: Data Type Mismatch in criteria expression

Status
Not open for further replies.

AppStaff

Programmer
Sep 21, 2002
146
0
0
US
UActive = Val(Nz(DSum("ST", "qrySELUpgradeBonus", "BuildID=forms!frmBuildsNew!BuildID and StartTime > '" & Eupgrade & "'"))) - Val(Nz((DSum("ET", "qrySELUpgradeBonus", "BuildID=forms!frmBuildsNew!BuildID and StartTime > '" & Eupgrade & "' and ActivityID='06'")))) * 60

Can anyone help me resolve this error. I've spent a good couple hours trying to figure out why I get a data type mismatch for this and no clue. Seems to make perfect sense to me, what am I missing?

dim Uactive as double
dim Eupgrade as double

Eupgrade= 8.5
ST is stored in fixed decimal format as is
ET and
StartTime

 
Hi,

What error?

Split the code and assign results to variables to try to isolate the error.



Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Code:
UActive = Val(Nz(DSum("ST", "qrySELUpgradeBonus", "BuildID=" & Forms!frmBuildsNew!BuildID & " AND StartTime > '" & Eupgrade & "'"))) - Val(Nz((DSum("ET", "qrySELUpgradeBonus", "BuildID=" & Forms!frmBuildsNew!BuildID & " AND StartTime > '" & Eupgrade & "' AND ActivityID='06'")))) * 60
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Error is in the topic. Data type mismatch. Thanks for response but the problem seems to be in the greater than line and not the forms reference.
 
Why are you using single quotes around number values?

Code:
UActive = Val(Nz(DSum("ST", "qrySELUpgradeBonus", "BuildID=" & Forms!frmBuildsNew!BuildID & " AND StartTime > " & Eupgrade ))) - Val(Nz((DSum("ET", "qrySELUpgradeBonus", "BuildID=" & Forms!frmBuildsNew!BuildID & " AND StartTime > " & Eupgrade & " AND ActivityID= 06")))) * 60
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
I believe the single quotes are required when using quotations within a function that has quotations around the parameters. Its the only way Access can differentiate between the inherint quotations in the function and the quoatations within the criteria. I have tried the syntax as many different ways as I can think with the same error as a result. :(

When I tried to recreate this expression using the graphical query tool, not surprisingly I get the same error.
 
It seems to me that this part:
"BuildID=" & Forms!frmBuildsNew!BuildID & " AND

should be
"BuildID= '" & Forms!frmBuildsNew!BuildID & "' AND
or
"BuildID= val('" & Forms!frmBuildsNew!BuildID & "') AND

Otherwise, I agree that the query should be broken down by moving some of the parameters into defined variable first.

Escolar [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top