Criteria in Query not giving correct records

K

kateri4482

I have the following query:

SELECT TblDailyCodes.Code, TblDailyCodes.Classroom, TblDailyCodes.Date,
TblDailyCodes.Time, TblReportRun.OnDate, TblReportRun.OnTime
FROM TblDailyCodes, TblReportRun
WHERE (((TblDailyCodes.Time)>(TblReportRun.OnTime)));

I get no records, even though when I look at the two tables I should have
some as the time in TblDailyCodes IS greater than the time in TblReportRun on
some records. When I remove the WHERE clause I get all of the records, which
I don't want. What am I doing wrong? Thanks for any suggestions!
 
L

Lord Kelvan

your problem may be that you are not joining the two tables

is one table linked to the other via a primary key or something
 
K

kateri4482

I had thought about the problem being because there is no join, but I didn't
think I needed one. There is no primary key defined in either table, so no
link. Do I need to create primary keys, and then create a join, in order to
have this query run as I want it to?
 
L

Lord Kelvan

umm ...

all tables should have primary keys it is a fundemental of table
structure

how are these tables releated
 
K

kateri4482

They are not really "related". The first table (TblDailyCodes) gets deleted
and then recreated with 6 different queries appending to it. The second
table (TblReportRun) gets created with a date and time every time I run a
certain report. So they are not really related. I just want to, I guess,
compare the dates between the two tables, and get the information where one
date from one table is greater than the date from the other table. Bottom
line: I am trying to create a report that gets information based on the last
time the report was run, and gives me JUST that information. I use the
select query to do this. Unless there is another way - or I have totally
confused you. Any additional help is appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top