Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with multiple select statement query

Status
Not open for further replies.

nikloskim

Technical User
Joined
Sep 14, 2007
Messages
2
Location
US
hi all... i am trying to grab rows based on two user-inputted criteria, 'theEmpID' and 'theDate'..and then, based on 'theDate' value, 'startDate' will be used as the criteria for the beginning date range up until the ending date range of 'theDate'

Code:
SELECT  *
FROM     [salesQuery]
WHERE  emp_id = theEmpID AND date_of BETWEEN startDate AND theDate
WHERE  (startDate = SELECT  DISTINCT (begin_date)
                   FROM     [salesQuery]
                   WHERE  date_of = theDate)

any pointers or help would be greatly appreciated
 
Are you attempting to use parameter prompts in queries and subqueries? IMHO, this type of user interface is not acceptable. Consider creating a form with controls for users to enter the criteria.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
thank you guys for responding; the parameters passed in by the user are from the form, selecting the employee name and selecting a date. then what I wanted to do was, based upon the selected employee and date, retreive the data for the week start up until the selected date, and sum them up... I realized that what I wanted was a week-to-date functionality, which I have found quite a few hits for searching around... sorry for the hassle, I'm not actually a programmer, just a financial analyst trying to expand on this system I am using
 
How about...
Code:
"SELECT *, begin_date as startDate " & _
"FROM salesQuery " & _
"WHERE emp_id = '" & Forms!yourForm!theEmpID & "'" & _
"AND date_of BETWEEN begin_date AND #" & _
Forms!yourForm!theDate & "#"

Note: not tested


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top