Solved

Select values from one table to use as parameters in another SQL in Access 2000

Posted on 2008-10-22
3
172 Views
Last Modified: 2010-05-18
I have a simple table named duedates that contains 1 record.  This record contains an OpenDate and CloseDate.

I want to grab these two values from this table and use them in a different SQL select to pull data from two tables that have been submitted between these two dates.

The code I have provided shows these dates as being 'hard coded' in the SQL select statement.

Is there a way from within Access 2000's SQL query view to create a SQL statement that will grab these two dates and use their values instead of having to hard code it or having to enter it manually each time the query is run.

Thanks in advance for your help!
SELECT Applications.Resa, Applications.ApplicationID AS ApplicationID, Applications.Equipment, Applications.ServiceLearning, Applications.MathScience, Applications.BudgetRequest, Applications.ProjectTitle, Applications.SubjectArea, Applications.GradeLevel, Applications.Summary, Applications.Objectives, Applications.ParentsInvolved, Applications.TeachersInvolved, Applications.StudentsInvolved, Applications.Caucasian, Applications.AfricanAmerican, Applications.Asian, Applications.LatinoHispanic, Applications.NativeAmerican, Applications.Other, Applications.EvaluateProject, Applications.Schedule, Budget.ApplicationID AS BudgetApplicationID, Budget.LineItem, Budget.Supplier, Budget.Quantity, Budget.UnitCost, Budget.TotalCost

FROM Applications INNER JOIN Budget ON Applications.ApplicationID=Budget.ApplicationID

WHERE Applications.DateSubmitted Between #7/31/2007# And #10/26/2007# And Applications.Resa=[Enter Resa Number]

ORDER BY Applications.Resa, Applications.ApplicationID;

Open in new window

0
Comment
Question by:sadoman
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Cedric_D
ID: 22777343
use CROSS JOIN:
SELECT Applications.Resa, Applications.ApplicationID AS ApplicationID, Applications.Equipment, Applications.ServiceLearning, Applications.MathScience, Applications.BudgetRequest, Applications.ProjectTitle, Applications.SubjectArea, Applications.GradeLevel, Applications.Summary, Applications.Objectives, Applications.ParentsInvolved, Applications.TeachersInvolved, Applications.StudentsInvolved, Applications.Caucasian, Applications.AfricanAmerican, Applications.Asian, Applications.LatinoHispanic, Applications.NativeAmerican, Applications.Other, Applications.EvaluateProject, Applications.Schedule, Budget.ApplicationID AS BudgetApplicationID, Budget.LineItem, Budget.Supplier, Budget.Quantity, Budget.UnitCost, Budget.TotalCost

FROM Applications INNER JOIN Budget ON Applications.ApplicationID=Budget.ApplicationID

CROSS JOIN DueDates

WHERE Applications.DateSubmitted Between DueDates.OpenDate And DueDates.CloseDate And Applications.Resa=[Enter Resa Number]

ORDER BY Applications.Resa, Applications.ApplicationID;

Open in new window

0
 

Author Comment

by:sadoman
ID: 22799644
I tried the cross join but it gives me an error message.  I've been searching information on cross joins and I'm not sure if it works in Access 2000.  
0
 
LVL 7

Accepted Solution

by:
Cedric_D earned 250 total points
ID: 22799882
well, then any CROSS JOIN can be replaced by INNER JOIN ON 1=1
or INNER JOIN ON T1.SOMEFIELD=T1.SOMEFIELD
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now