Hello, and thanks in advance for any advice.
I can run the following IIf statements without issue independently , but when I combine them together I get a "Data Type Mismatch" error. Here are the separate statements: - Exp1: IIf([Tot_Hours]>=24,[Wgt_Time],"")
-
-
Exp2: IIf(([On_TG]<=[To_TG]) And ([On_TG]<=12 And [To_TG]>=12),[Wgt_Time],"")
Here's what they look like when combined: - CombExp: IIf([Tot_Hours]>=24,[Wgt_Time],IIf(([On_TG]<=[To_TG]) And ([On_TG]<=12 And [To_TG]>=12),[Wgt_Time],""))
Descriptions of the values in the expressions are as follows:
Tot_Hours is a DateDiff("h") on two dates, and formatted as a general number
On_TG and To_TG are both DatePart("h) of two different dates, and formatted as a general number
Wgt_Time: 1/([Tot_Hours]+1)
Again, appreciate the assistance.
12 7380
I have had similar problems sometimes, but they were due to some residual code I could not see in the Control Source field. Make sure you clean out that field completely, then start fresh, if you have a line break character in there it might buck.
I could not try your code but if your two seperate functions are working, it looks good.
I suggest start with the first one, make it work again, then add the second one but making the variables constant values: - IIf([Tot_Hours]>=24,[Wgt_Time],IIf((12<=12) And (12<=12 And 12>=12),[Wgt_Time],""),""))
if it works, change one variable at a time and assess from there
NeoPa 32,556
Expert Mod 16PB
Jon, interesting question and well laid out. I've looked at your three expressions very carefully and I have to say I don't see any divergence or reason for the third one to fail. I would suggest that each of the comparison expressions is contained in parentheses (as below), but this is common between expressions two and three so I hold little hope it will resolve your issue. - CombExp: IIf([Tot_Hours]>=24,[Wgt_Time],IIf(([On_TG]<=[To_TG]) And ([On_TG]<=12) And ([To_TG]>=12),[Wgt_Time],""))
Generally, in situations like this, I find the answer lies in something different somewhere else that you don't comment on simply because you're totally unaware of what it is. This can only really be found by looking at the whole database.
Tot_Hours is a DateDiff("h") on two dates, and formatted as a general number
On_TG and To_TG are both DatePart("h) of two different dates, and formatted as a general number
Wgt_Time: 1/([Tot_Hours]+1)
Just to be clear, are they also STORED as a number, or merely formated as one?
Good question re: stored vs. formatted. Probably just formatted.
Those values are derived from date fields, and I used the properties to format to general number.
How do I store them as numbers instead of only formatting them?
Well DateDiff returns a long, and DatePart returns a Integer, so unless you have since used a FORMAT function (which returns a string!) then I don't think that should give trouble. Are the fields in question fields in a query or in a table? If in a table, what is the type of the field? Text, numeric, or date/Time?
The fields are in the query, but are derived from fields in the same query that come from a ODBC connection to an oracle DB table and those are date/time.
Sorry, but Im am simply all out of ideas/suggestions.
No problem, thanks for the brain power though. At least this is validating...since I was going crazy trying to correct it thinking that there was something obvious I wasn't looking at.
Good to know that at least it isn't a newb issue, as I'm relatively new to working in Access.
Can you test whether you get the error specifically when the second IIF is true (returning [Wgt_Time]) or when it is false (returning "")?
Do all rows have a non-Null value of [Wgt_Time]?
There are no null values, but I did notice that some have negative values.
I figured it wouldn't be the issue though since it runs successfully when it isn't being combined with the first IIF expression.
Just a quick follow up to close this out...
Instead of trying to edit my existing query, I started over with a new one and the expressions work.
... residual code or character syndrome, I call it :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Laurel |
last post by:
this is driving me crazy. i need to use a form control as a criteria
in a select query, and the control's value is set depending upon what
a user selects in an option group on the form. the query...
|
by: Martin Lacoste |
last post by:
Is there some issue with using too many left/right/mid/len functions
in queries? Depending on the usage, they work fine, but... then
there's here:
SELECT Master_CAO.Incipit,...
|
by: N J |
last post by:
Hi,
CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " &
Me.txtOrderNumber & ";", dbfailonerror
Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS...
|
by: martlaco1 |
last post by:
Trying to fix a query that (I thought) had worked once upon a time, and
I keep getting a Data Type Mismatch error whenever I enter any criteria
for an expression using a Mid function. Without the...
|
by: igor.barbaric |
last post by:
Hello!
I have created a very simple query like this:
SELECT Tasks.Name, DurationHrs(,) AS
Duration
FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID;
The above query works fine....
|
by: lalbee |
last post by:
I am trying to use the Dcount function but receive a data type mismatch
error, can someone help me determine the cause?
Count: DCount("","qry-final everhome results"," <'0' ")
Thanks!
|
by: christianlott1 |
last post by:
Taken (and modded) from http://www.codeguru.com/vb/gen/vb_misc/tips/
article.php/c13137
'RESULTS' table:
REF_STRING - TEXT 250
TEST_STRING - TEXT 250
MATCH_VALU - SINGLE FIXED 2 DECIMAL...
|
by: psychomad |
last post by:
Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!
The Error is:
Server Error in '/' Application....
|
by: Lysander |
last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
|
by: hype261 |
last post by:
So I have a SQL Query I am trying to author and it keeps giving me a Data Type mismatch error which I can't seem to see. Exact error message is Data type mismatch in criteria expression.
Here is...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |