I have 2 queries which have been working for the last 2 or 3 years but last week decided to start giving me a data type mismatch error. Query 1 looks at how many records have been created in the last 31 days so that I can count visits, and query 2 looks at how many visits I have each day (Today)
I rewrote the queries and they worked for a few hours and then fell over again. I have tried to compact and repair but that hasn't changed anything. I made a different query and added a new field to the table that displayed the date without the time and based the query on that field instead of the query field [Date31] and that worked up until today but now if I run the query it returns all the records but then gives the data type mismatch error and on clicking ok, all fields change to “#Name?” If I take out the Criteria ie ask for all records, all 29k records are returned as expected. As soon as I filter it all goes south.
I really don’t know where to go from here? Is my database corrupted and if so do I need to rebuild the entire back end and import the data? Any advice would be greatly appreciated, my ability level in access terms is mediocre at best
SQL for Query 1 “AttMonth” is as follows. - SELECT Attendance.Att_ID
-
, Attendance.Att_ClientNo
-
, Attendance.Att_Date
-
, DateValue([Att_date]) AS Date31
-
FROM Attendance
-
WHERE (((DateValue([Att_date]))>Date()-31))
-
ORDER BY DateValue([Att_date]);
Thank you.
Double check your SQL - typically there's an extra/missing something (^_^) I've tested the following within my test database by copying and modifying one of the data tables to match the fields you gave - it returned 120 records: - SELECT Attendance.Att_ID
-
, Attendance.Att_ClientNo
-
, Attendance.Att_Date
-
, DateValue([Att_date]) AS Date31
-
FROM Attendance
-
WHERE ( [Att_Date] > Dateadd("d",-31,Date()))
-
ORDER BY [Att_date];
6 4632 zmbd 5,501
Expert Mod 4TB
Have you recently upgraded your versions of Office/Access?
Are people with different versions of Office/Access opening your database?
You mention frontend/backend in your post, are your queries in the backend?
You might want to
"[Att_Date]" is this a text field in the table?
If [Att_Date] is a date field then you should be able to remove the datevalue() function and change the "Date() - 31" to Dateadd("d",-31,Date()) so that you are dealing with all date/time datatype.
Thanks for your reply.
"[Att_Date]" is a date/time field in the table
All the queries are in the front end, only tables sit on my back end.
Removing the datevalue() function and using Dateadd in the criteria stops the error but returns 0 records, have I misunderstood?
Thanks for your help.
" I made a different query and added a new field to the table that displayed the date without the time and based the query on that field instead of the query field [Date31]"
How did you do this? It really sounds like there is a miscommunication between the DateTime / Date fields. I would check the property sheets for the appropriate fields you think are giving the error and double check that Time isn't being pulled in from somewhere.
You can always try to use formatting to get a desired results. - Format([Att_Date], "Short Date")
or something similar
zmbd 5,501
Expert Mod 4TB
Double check your SQL - typically there's an extra/missing something (^_^) I've tested the following within my test database by copying and modifying one of the data tables to match the fields you gave - it returned 120 records: - SELECT Attendance.Att_ID
-
, Attendance.Att_ClientNo
-
, Attendance.Att_Date
-
, DateValue([Att_date]) AS Date31
-
FROM Attendance
-
WHERE ( [Att_Date] > Dateadd("d",-31,Date()))
-
ORDER BY [Att_date];
Double checked my SQL and there was indeed an error. I am still at a loss as to why a query that was happy for 2 or 3 years would decide to stop behaving but using dateadd is doing the job nicely so I wont worry :)
Thank you so much for your help it is much appreciated.
zmbd 5,501
Expert Mod 4TB
I usually blame Updates and MS Gremlins?!
However, Ghost in the Shell?
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: s_gregory |
last post by:
The mdb is considerable size 70 +- mb. A complex union query was
working well, but when an additional union select... was added into
the query, selecting identical fields from a different source,...
|
by: news.paradise.net.nz |
last post by:
I have been developing access databases for over 5 years.
I have a large database and I have struck this problem with it before
but can find nothing in help or online. Access 2000
I have a query...
|
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...
|
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: 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: bleighfield |
last post by:
Hi everyone
Hope someone can help with this one..
Background:
I work in vehicle fleet, I have built something to 'predict' when a
car/van service is due (it's fairly simple, calculates...
|
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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,...
| |