If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Query brings back record when it shouldn't

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-06, 04:51
KevCB226 KevCB226 is offline
Registered User
 
Join Date: Sep 2005
Posts: 240
Query brings back record when it shouldn't

Hi,

I'm getting an unusual issue with a query I have made.
The query is meant to show records of schools that haven't had any visits from our liaison officers.

To do this I linked both the schools details table and the visits table. I then checked to see if the date of the visit is not between the previous academic year, and display the schools address details.

The query works on all but one record. When I view the visit table the record is in there and between the date ranges. But the query seems to bring back the record as having no date at all.

This is the query I am using:

Code:
SELECT dbo_tblSchoolDetails.SchoolName, dbo_tblSchoolDetails.SchoolED, dbo_tblSchoolDetails.Addr1, dbo_tblSchoolDetails.Addr2, dbo_tblSchoolDetails.Town, dbo_tblSchoolDetails.County, dbo_tblSchoolDetails.PostCode, dbo_tblSchoolDetails.PostCode2, dbo_tblVisits.EventDate, IIf([EventDate] Not Between "01/09/" & CStr(IIf(Month(Date())<9,Year(Date())-1,Year(Date()))) And "31/08/" & CStr(Year(Date())),"N","Y") AS Expr1
FROM dbo_tblSchoolDetails LEFT JOIN dbo_tblVisits ON dbo_tblSchoolDetails.ID = dbo_tblVisits.ID
WHERE (((IIf([EventDate] Not Between "01/09/" & CStr(IIf(Month(Date())<9,Year(Date())-1,Year(Date()))) And "31/08/" & CStr(Year(Date())),"N","Y"))="Y"));
I'm not sure why it is doing this, but the first thing I could think of, is that it maybe something to do with the linked tables from SQL Server 2000, but the date is also in the table on the server, unless it is something else.

Is the criteria on my query correct?

Thanks

EDIT: Sorted now, I was making the stupid mistake of linking the wrong IDs.

Last edited by KevCB226; 09-13-06 at 06:30.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On