Hi. I need to run a query to return a list of dates for which there are no records. From suggestions on the internet, I've created a separate table containing one field called "Record_Date" with the range of dates that I need to compare with ("DateRangeTable").
The table I'm searching has 14 fields, but one of them is also named "Record_Date", the same as the field in the date range table. The SQL I've got is:
Code:
SELECT DISTINCT DateRangeTable.Record_Date
FROM DateRangeTable, WeeklyTimesheetQueryResults
WHERE (((DateRangeTable.Record_Date)<>[WeeklyTimesheetQueryResults].[Record_Date]));
However, this query returns all the dates listed in the date range table, even if there is a record with a matching date in the recordset table. My only guess is the date formatting. Both "Record_Date" fields in both tables are of the "Date/Time" Data Type, but for some reason in the record-set the field shows only the date, whereas in the DateRangeTable it shows both date and time. Even if I go to design view and format as short date, if I click on the field it changes to show the time as well, so I'm assuming that regardless of formatting, the base data still holds the date and time. But the record-set table doesn't behave the same way. I'm not sure if my data entry form is not putting a date/time in there, or what might be the problem; since it loads it from a datepicker, I would assume that the time comes with the date automatically.
If I can't change the record-set table to match the DateRangeTable (by adding the time to the date), my next solution would be to go the other way around, that is, change the DateRangeTable to match the record-set table, by removing the time from the date (since all I really need here is the date, and I was planning on stripping it out with report formatting anyway).
To do that, I'd have to know how to change some SQL that is called from a module, which is behind a form with a textbox, also with a datepicker:
Code:
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 6 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 5 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 4 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 3 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 2 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date - 1 & "#);"
DoCmd.RunSQL "INSERT INTO DateRangeTable ([Record_Date])" & "VALUES(#" & "" & Me!WE_Date & "#);"
Basically, it takes the date I enter into the textbox (Week ending date, or "WE_Date") and extrapolates the dates for the week, then enters them into the table. Is there some tweaking I need to do here? Again, this is all from the wild guess that my Record_Date fields are not matching, because for some reason my Unmatched query isn't catching anything.
Where should I start?
Thanks for any suggestions.