473,467 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Another data type mismatch when entering criteria

5 New Member
In my real estate access database, I'm trying to create a report that will give me all the properties that are due for a lease renewal this year.

I've been able to use datediff to tell me how many years I have until the renewal date, but for some reason, I cannot select just the ones for this year and next year (where datediff < 1) or even between 0 and 1. I can run the query fine without the criteria, but once I plug any kind of criteria in, I immediately get the data type mismatch.

I'm running Access 2000, on Windows XP SP2

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. Property.Name, 
  3. Property.Number, 
  4. Property.CurrentLeaseDate,
  5. (DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])) AS RenewDate,
  6. DateDiff('yyyy',(DateAdd('yyyy',[Property].[CurrentReviewPattern,[Property].[CurrentLeaseDate])),Date()) AS Years
  7.  
  8. FROM 
  9. Property
  10.  
  11. WHERE (((Property.CurrentReviewPattern)>"1") AND ((Property.CurrentLeaseDate) Is Not Null)) 
  12.  
  13.  
Thanks in advance!

Joy
Sep 21 '06 #1
8 5670
PEB
1,418 Recognized Expert Top Contributor
Hi,

So if this field
Property.CurrentReviewPattern is a string /text/ and not number field you will have multiple type conversion errors and your problem wouldn't be in your criteria!

So obviously your field is numeric but you create a mistake in your condition typing >"1"

Try only >1

:)
Sep 21 '06 #2
mjoytan
5 New Member
Thank you for the advice, and I actually tried putting 1 without the quotes the first time, but when I run the query, it puts the quotes in for me.

I checked the data type and it is in fact, "number". When I originally wrote the query, I used "is not null" instead of ">1" (sorry about the use of quotes, I'm not actually typing it in the criteria area with the quotes), it gave me a data type mismatch. I was just making sure that the null fields weren't in my report.

I tried to convert the datediff result to an integer, but that didn't seem to do anything.

This is something that was odd, though. When I tried to set a criteria on the resulting field (dateadd("yyyy", [pattern], [leasedate]) , and wanted all records that contained "2006" (like "*2006), I still got a data type mismatch. Do I have to convert the date too? It looks like a date in the resulting dataset. The datediff field seems to come out with the expected result....
Sep 21 '06 #3
PEB
1,418 Recognized Expert Top Contributor
It gives sometimes a variant expression!

So

the int() function doesn't convert it is it?
Sep 21 '06 #4
mjoytan
5 New Member
I did try the INT() conversion on the Years field, but I still can't use the >1 criteria. I can't use any criteria that I try, > "1", or even "is not null". Nothing.

Should I try the INT() conversion on the renewdate field as well? Or do my Years field calculated differently? Am I using datediff correctly, or do I need to convert int within the expression?
Sep 21 '06 #5
PEB
1,418 Recognized Expert Top Contributor
try this:
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. Property.Name, 
  3. Property.Number, 
  4. Property.CurrentLeaseDate,
  5. (DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])) AS RenewDate,
  6. DateDiff('yyyy',(DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])),Date()) AS Years
  7.  
  8. FROM 
  9. Property
  10.  
  11. WHERE (((Property.CurrentReviewPattern)>1) AND ((Property.CurrentLeaseDate) Is Not Null)) ;
  12.  
  13.  
Not there was an omitted bracket ] in your SQL!

:)
Sep 21 '06 #6
mjoytan
5 New Member
Hi PEB-

I put the missing bracket back in..must have deleted it when I was copying the query back and forth from textpad.

Still the same error when I try to put criteria in. Is there a different way that I can calculate the # of years from today that the renewal date is coming up? Is datediff the only way to do it?
Sep 21 '06 #7
PEB
1,418 Recognized Expert Top Contributor
Hi,

In fact in this cases I delete the functions to see which expression gives me the problem...

So in your case try to delete first the one condition then the second one restoring the previous

And then proceed with the functions...

When you know in which expression is the problem it should be easier to correct it...

Are you sure that it is in the expression with >"1"?

:)
Sep 22 '06 #8
mjoytan
5 New Member
I'm sorry, I didn't mean to be confusing. I'm trying run the query where my datediff expression ("Years") is >=1. Access keeps giving me an error, everytime I put it in, which is why it's not in the original statement. It should read:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. Property.Name, 
  3. Property.Number, 
  4. Property.CurrentLeaseDate,
  5. Property.CurrentReviewPattern,
  6. (DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])) AS RenewDate,
  7. DateDiff('yyyy',(DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])),Date()) AS Years
  8.  
  9. FROM 
  10. Property
  11.  
  12. WHERE (((Property.CurrentReviewPattern)>1) AND 
  13. ((Property.CurrentLeaseDate) Is Not Null)) AND 
  14. ((Int(DateDiff('yyyy',(DateAdd('yyyy',[Property].[CurrentReviewPattern],[Property].[CurrentLeaseDate])),Date())))>1))
  15.  
  16.  
It is the last part of the where statement that is giving me the problem. Each time I put a criteria in this column, that's when the data type mismatch happens.
Sep 22 '06 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
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...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
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....
2
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....
5
by: blackburnj55 | last post by:
Hi, I am constructing a website for a bike shop. I am using dreamweaver and an access database to create it. I have made a query where two criteria are entered to get results. These are :...
19
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...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.