To enter date range once only for main- and sub forms

G

Guest

The main form “frm_Days_At_Hospital†has two sub forms. All forms should show
data of the same date range (i.e. Admission Date from 03/01/06 till 03/19/06)
having the user to state the date range for the main form only and not for
the two sub forms individually also (In total thus three times).

SQL-Statement of the main form’s query:
SELECT [AD Absent Sick].[Admission Date], [AD Absent Sick].Discharged,
(DateDiff("d",[Admission Date],[Discharged])+1) AS DaysDischarged,
(DateDiff("d",[Discharged],Date())) AS DaysDischargedTillToday,
(DateDiff("d",[Admission Date],Date())+1) AS DaysAdmTillToday,
[DaysDischargedTillToday]+[DaysDischarged] AS Substract, [AD Absent
Sick].Clinic, [AD Absent Sick].[Admission Date] AS StartDate, [AD Absent
Sick].Discharged AS EndDate
FROM [AD Absent Sick]
WHERE ((([AD Absent Sick].[Admission Date]) Between [StartDate] And
[EndDate]));

SQL-Statement of one of the sub form’s query:
SELECT [AD Absent Sick].[Admission Date], [AD Absent Sick].Discharged, [AD
Absent Sick].Clinic, (DateDiff("d",[Admission Date],[Discharged])+1) AS
DaysDischarged, (DateDiff("d",[Discharged],Date())) AS
DaysDischargedTillToday, (DateDiff("d",[Admission Date],Date())+1) AS
DaysAdmTillToday, [DaysDischargedTillToday]+[DaysDischarged] AS Substract
FROM [AD Absent Sick]
WHERE ((([AD Absent Sick].Clinic)="BBG"));

Thank you for any help
 
T

Tom Ellison

Dear Up:

I expect your best bet would be to put controls on the main form for start
and end dates and reference those in the queries.

These references within the queries would be:

[Forms]![FormName]![ControlName]

In the above, replace FormName and ControlName with the actual names of the
form and controls for start and end dates.

Tom Ellison
 

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