Parameter query (1 Viewer)

capogna1

Member
Local time
Today, 07:23
Joined
Aug 8, 2019
Messages
46
Hi everyone!
So my query looks up between dates, I enter "Start date" and "End date" and this works.
I would like those 2 dates to come up on my report that look at this query.
I might be real simple to do but been trying and can't get it.

Thanks in advance!!!
 

XPS35

Active member
Local time
Today, 13:23
Joined
Jul 19, 2022
Messages
160
Make form to enter the dates. Also add a button to open the report.
Both in your query as in your report you can refer to the controls on the form.
 

sonic8

AWF VIP
Local time
Today, 13:23
Joined
Oct 27, 2015
Messages
998
I would like those 2 dates to come up on my report that look at this query.
Include the parameters not only as criteria but also as output columns of your query. Then you can easily bind them to controls on your report.
E.g.

Code:
SELECT *, [StartDate], [EndDate]
FROM YourTable
WHERE SomeDate BETWEEN [StartDate] AND [EndDate]
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:23
Joined
Sep 21, 2011
Messages
14,371
I thought you might be able to refer to the form dates directly, but I just get a blank field?
I used the builder to get the form control reference
Code:
SELECT Transactions.Date, Transactions.Description, [Forms]![frmEmails]![EmailDate] AS Expr1
FROM Transactions;
1666195740075.png
 

capogna1

Member
Local time
Today, 07:23
Joined
Aug 8, 2019
Messages
46
Include the parameters not only as criteria but also as output columns of your query. Then you can easily bind them to controls on your report.
E.g.

Code:
SELECT *, [StartDate], [EndDate]
FROM YourTable
WHERE SomeDate BETWEEN [StartDate] AND [EndDate]
How do I include output column to my query?
I'm trying to have the Between Dates from "Q_Completed_By_Date1" added to my report "R_CompletedByDate" so the report shows the dates entered in criteria parameter.
 

Attachments

  • Medical Records Review - V2 yes - Copy (2).zip
    669.3 KB · Views: 58

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:23
Joined
May 21, 2018
Messages
8,555
How about stripping down that database to the relevant forms tables and queries and explain where to look. Most people do not want to waste their time blindly wading through that. Get rid of all password forms.
 

capogna1

Member
Local time
Today, 07:23
Joined
Aug 8, 2019
Messages
46
How about stripping down that database to the relevant forms tables and queries and explain where to look. Most people do not want to waste their time blindly wading through that. Get rid of all password forms.
 

Attachments

  • Medical Records Review - V2 stripped.zip
    656.6 KB · Views: 65

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:23
Joined
May 21, 2018
Messages
8,555
I did exactly as @sonic8 instructed
Code:
SELECT
  T_Encounter.Type_Of_Encounter AS [Type Of Encounter],
  T_Encounter.Attending_Name AS [Attending Name],
  T_Encounter.Admit_Date AS [Admission Date],
  T_Encounter.Discharge_Date AS [Discharge Date],
  T_Encounter.Treating_SpecialityID AS [Treating Speciality ID],
  T_Encounter.DateReviewed AS [Date Reviewed],
  T_Encounter.Reviewer,
  DateDiff(
    "d", [Discharge_Date], [ReviewCompletedDate]
  ) AS [Days Old],
  T_Encounter.ReviewCompletedDate AS [Review Completed Date],
  [Enter your start date for report] AS StartDate,
  [Enter your End date for report] AS EndDate
FROM
  T_Encounter
  INNER JOIN Q_DaysOld ON T_Encounter.ID_Enc = Q_DaysOld.ID_Enc
WHERE
  (
    (
      (
        T_Encounter.ReviewCompletedDate
      ) Is Not Null
      And (
        T_Encounter.ReviewCompletedDate
      ) Between [Enter your start date for report]
      And [Enter your end date for report]
    )
  );

Start.png

I just added the calculated fields
StartDate: [Enter your start date for report]
EndDate: [Enter your End date for report]

FYI the text in the Parameters has to be EXACT. One spelling error and this does not work.
I would make a form to do this so that you can validate the dates to ensure start is before end date and both are valid dates. Then you could also give a nice date picker to make entering dates easier and less error prone.
 
Last edited:

capogna1

Member
Local time
Today, 07:23
Joined
Aug 8, 2019
Messages
46
I did exactly as @sonic8 instructed
Code:
SELECT
  T_Encounter.Type_Of_Encounter AS [Type Of Encounter],
  T_Encounter.Attending_Name AS [Attending Name],
  T_Encounter.Admit_Date AS [Admission Date],
  T_Encounter.Discharge_Date AS [Discharge Date],
  T_Encounter.Treating_SpecialityID AS [Treating Speciality ID],
  T_Encounter.DateReviewed AS [Date Reviewed],
  T_Encounter.Reviewer,
  DateDiff(
    "d", [Discharge_Date], [ReviewCompletedDate]
  ) AS [Days Old],
  T_Encounter.ReviewCompletedDate AS [Review Completed Date],
  [Enter your start date for report] AS StartDate,
  [Enter your End date for report] AS EndDate
FROM
  T_Encounter
  INNER JOIN Q_DaysOld ON T_Encounter.ID_Enc = Q_DaysOld.ID_Enc
WHERE
  (
    (
      (
        T_Encounter.ReviewCompletedDate
      ) Is Not Null
      And (
        T_Encounter.ReviewCompletedDate
      ) Between [Enter your start date for report]
      And [Enter your end date for report]
    )
  );

View attachment 103990
I just added the calculated fields
StartDate: [Enter your start date for report]
EndDate: [Enter your End date for report]

FYI the text in the Parameters has to be EXACT. One spelling error and this does not work.
I would make a form to do this so that you can validate the dates to ensure start is before end date and both are valid dates. Then you could also give a nice date picker to make entering dates easier and less error prone.T

I did exactly as @sonic8 instructed
Code:
SELECT
  T_Encounter.Type_Of_Encounter AS [Type Of Encounter],
  T_Encounter.Attending_Name AS [Attending Name],
  T_Encounter.Admit_Date AS [Admission Date],
  T_Encounter.Discharge_Date AS [Discharge Date],
  T_Encounter.Treating_SpecialityID AS [Treating Speciality ID],
  T_Encounter.DateReviewed AS [Date Reviewed],
  T_Encounter.Reviewer,
  DateDiff(
    "d", [Discharge_Date], [ReviewCompletedDate]
  ) AS [Days Old],
  T_Encounter.ReviewCompletedDate AS [Review Completed Date],
  [Enter your start date for report] AS StartDate,
  [Enter your End date for report] AS EndDate
FROM
  T_Encounter
  INNER JOIN Q_DaysOld ON T_Encounter.ID_Enc = Q_DaysOld.ID_Enc
WHERE
  (
    (
      (
        T_Encounter.ReviewCompletedDate
      ) Is Not Null
      And (
        T_Encounter.ReviewCompletedDate
      ) Between [Enter your start date for report]
      And [Enter your end date for report]
    )
  );

View attachment 103990
I just added the calculated fields
StartDate: [Enter your start date for report]
EndDate: [Enter your End date for report]

FYI the text in the Parameters has to be EXACT. One spelling error and this does not work.
I would make a form to do this so that you can validate the dates to ensure start is before end date and both are valid dates. Then you could also give a nice date picker to make entering dates easier and less error prone.
Thanks Much!!!
 

Users who are viewing this thread

Top Bottom