G
Guest
I sure hope I can explain this clearly!
I have two tables: Table 1 (tblJobs) and Table 2 (tblJobTickets). For each
job in tblJobs there could be one or more listings in the tblJobTickets. What
happens here is that when we get a new job it gets listed in the tblJobs.
Once the job goes into production we issue it one or more job tickets and
they get listed in the tblJobTickets. What I want to do is to pull all jobs
from tblJobs that fit certain criteria (all jobs that aren't completed or all
jobs entered in the last week, etc.) and display some of the info about that
job from tblJobs and that job's ticket number from tblJobTickets if it has
been issued one. Every job gets a unique ID and that is the field that links
the two tables together in the Relationship window. I have tried using
different Joins in my SQL statements and different relationship types but I
can't seem to get the records I want. Here is an example of one of my SQL
statements:
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, " & _
"tblJobs.txtJobName, tblJobs.dtEntered, tblJobs.dtModified, " & _
"tblJobs.Status, tblJobs.txtUsername, tblJobs.intStatusSort " & _
"FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID
= tblJobs.intJobID " & _
"WHERE (((tblJobs.Status) <> 'Completed'))
Here is an example of what I get with this sql statement: In tblJobs I have
a job with ID 630. This particular job has seven job ticket listings in
tblJobTickets. When I run this SQL statement I get all seven listings and not
just one. I wish I knew how to limit the records returned to those with
unique Job ID's because that seems like what I want. Even though Job number
630 has seven tickets if I could limit the SQL results to those with Unique
Job ID's I would be getting only one listing for Job # 630.
Thanks in advance to any and all who take the time to share their advice. It
is greatly appreciated!
I have two tables: Table 1 (tblJobs) and Table 2 (tblJobTickets). For each
job in tblJobs there could be one or more listings in the tblJobTickets. What
happens here is that when we get a new job it gets listed in the tblJobs.
Once the job goes into production we issue it one or more job tickets and
they get listed in the tblJobTickets. What I want to do is to pull all jobs
from tblJobs that fit certain criteria (all jobs that aren't completed or all
jobs entered in the last week, etc.) and display some of the info about that
job from tblJobs and that job's ticket number from tblJobTickets if it has
been issued one. Every job gets a unique ID and that is the field that links
the two tables together in the Relationship window. I have tried using
different Joins in my SQL statements and different relationship types but I
can't seem to get the records I want. Here is an example of one of my SQL
statements:
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, " & _
"tblJobs.txtJobName, tblJobs.dtEntered, tblJobs.dtModified, " & _
"tblJobs.Status, tblJobs.txtUsername, tblJobs.intStatusSort " & _
"FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID
= tblJobs.intJobID " & _
"WHERE (((tblJobs.Status) <> 'Completed'))
Here is an example of what I get with this sql statement: In tblJobs I have
a job with ID 630. This particular job has seven job ticket listings in
tblJobTickets. When I run this SQL statement I get all seven listings and not
just one. I wish I knew how to limit the records returned to those with
unique Job ID's because that seems like what I want. Even though Job number
630 has seven tickets if I could limit the SQL results to those with Unique
Job ID's I would be getting only one listing for Job # 630.
Thanks in advance to any and all who take the time to share their advice. It
is greatly appreciated!