dbTalk Databases Forums  

Office 2010 inconsistent about Data type mismatch?

comp.databases.ms-access comp.databases.ms-access


Discuss Office 2010 inconsistent about Data type mismatch? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Composer
 
Posts: n/a

Default Office 2010 inconsistent about Data type mismatch? - 07-18-2011 , 04:00 PM






The query below has worked fine under Access 2003. We're about to
convert to Office 2010 so I tested it there, and received "Data type
mismatch in criteria expression".

One might guess that Microsoft have tightened up the rules.
DayTitle.DateKey is a Date/Time field, whereas UserVariables.DataValue
is a Text field.

But maybe it's not so simple. In Office 2010, I created a new
database, typing in the table definitions, values, and query by hand
very carefully. They appear to be the same as the old database. But
now the query works!

Thinking that a database in 2010 format might work where a 2003-format
database would not, I created a blank database and imported the entire
contents of the old database, in effect converting it to 2010 format
(I hope). But in this case the query did not work.

My analytical powers are being challenged...

SELECT *
FROM DayTitle
WHERE (DateKey BETWEEN
(SELECT DataValue FROM UserVariables WHERE Keyword='Reporting
date from')
AND
(SELECT DataValue FROM UserVariables WHERE Keyword='Reporting
date to'))
ORDER BY DateKey;

Reply With Quote
  #2  
Old   
Composer
 
Posts: n/a

Default Re: Office 2010 inconsistent about Data type mismatch? - 07-19-2011 , 05:50 AM






I won't bore you with further complications. The solution was to
force text fields into date fields:

SELECT *
FROM DayTitle
WHERE (DateKey BETWEEN
* * *(SELECT DateValue(DataValue) FROM UserVariables WHERE
Keyword='Reporting date from')
* * *AND
* * *(SELECT DateValue(DataValue) FROM UserVariables WHERE
Keyword='Reporting date to'))
ORDER BY DateKey;

Reply With Quote
  #3  
Old   
Access Developer
 
Posts: n/a

Default Re: Office 2010 inconsistent about Data type mismatch? - 07-19-2011 , 02:48 PM



It doesn't make much sense to keep dates in text fields when there is a
Date/Time field and also a Date/Time variable, and a plethora of built-in
functions for calculating date/time values (which will not always work, or
not work well, as you see, when you try to use text for dates).
--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access


"Composer" <composer (AT) uwclub (DOT) net> wrote

I won't bore you with further complications. The solution was to
force text fields into date fields:

SELECT *
FROM DayTitle
WHERE (DateKey BETWEEN
(SELECT DateValue(DataValue) FROM UserVariables WHERE
Keyword='Reporting date from')
AND
(SELECT DateValue(DataValue) FROM UserVariables WHERE
Keyword='Reporting date to'))
ORDER BY DateKey;

Reply With Quote
  #4  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: Office 2010 inconsistent about Data type mismatch? - 07-20-2011 , 04:32 AM



"Composer" wrote in message
news:85acdb6f-1734-4e55-b9a2-4b775f488ac9 (AT) e35g2000yqc (DOT) googlegroups.com...

Quote:
I won't bore you with further complications. The solution was to
force text fields into date fields:

This usually suggests that on the new machine or different computer that
regional date defaults or formats are different.

I tend to find that "most" of the problems in regards to date issues tend to
be that of date settings on the computer,
especially when letting access "cast" the string into a date for you.

In those cases (if possible), when working with dates, you want to force the
issue so to speak,
and use real date columns and real date expressions.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kallal (AT) msn (DOT) com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.