Results 1 to 4 of 4
  1. #1
    OtakiriLad is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2015
    Location
    Golden Beach, Queensland
    Posts
    4

    Passing parameter form value to a query result

    I am attempting to execute a query which will be used as the basis for a report which extracts records from a table where the date in the table is less than or equal to a supplied parameter form date.

    I want to use the parameter date in the header of the report so need to pass it in the query result (yes every record in the query result will contain the same value).

    The query I have created works beautifully in generating the correct set of records but the value of the parameter in each record is blank (or null?)

    The SQL is as follows . . .



    SELECT tblDocument.Number, tblDocument.Title, tblDocument.StatusID, tblPerson.FirstName & " " & tblPerson.LastName AS AuthorName, tblActivity.Version, tblActivity.Description, tblActivity.Date, [Forms]![frmParm1a]![ReviewDueDate] AS ReviewDueDate, tblDocument.DateNextReview
    FROM tblStatus INNER JOIN (tblPerson INNER JOIN (tblDocument INNER JOIN tblActivity ON tblDocument.SysGenID = tblActivity.DocumentID) ON tblPerson.SysGenID = tblDocument.AuthorID) ON tblStatus.SysGenID = tblDocument.StatusID
    WHERE (((tblDocument.DateNextReview)<=[Forms]![frmParm1a]![ReviewDueDate]) AND ((tblStatus.Name)="Existing")) OR (((tblStatus.Name)="Proposed")) OR (((tblDocument.DateNextReview)<=[Forms]![frmParm1a]![ReviewDueDate]) AND ((tblStatus.Name)="Draft"))
    ORDER BY tblDocument.Number, tblDocument.Title, tblActivity.Version;

    Why is ‘ReviewDueDate’ blank?

    Thanks in advance
    Dave

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    is it blank in the query or in the form or report?

    do you have a field called ReviewDueDate in one of the tables in your query?

  3. #3
    OtakiriLad is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2015
    Location
    Golden Beach, Queensland
    Posts
    4
    Thanks Ajax for the response. The result rows in the query are blank and that field name is unique to the parameter form - it does not exist in any other table or query.

    A curious thing is that if I run the query direct and supply the parameter from the query prompt rather than from the form the field populates correctly.

    I have also generated a workaround by referencing the form field ( [Forms]![frmParm1]![ReviewDueDate ) directly in the report and that works. However I would prefer a solution to populate the query result as there is no guarantee that in the future the parameter form will still exist at the time of the report generation.

    Cheers
    Dave

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    If you cannot guarantee that the parameter form will be open, you will have to try to assign the form control value to a variable. If it fails, you can direct execution to a part of the routine that supplies it some other way. As for why your work around works but the posted sql does not, perhaps it is the extra "a"? [Forms!frmParm1a.ReviewDueDate]

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-09-2015, 09:27 AM
  2. Passing parameter from form to query
    By rhubarb in forum Forms
    Replies: 3
    Last Post: 05-03-2015, 10:29 AM
  3. Passing textbox value into sql query parameter
    By gustavoavila in forum Access
    Replies: 7
    Last Post: 04-23-2014, 04:00 PM
  4. Replies: 1
    Last Post: 01-24-2012, 12:47 AM
  5. Replies: 10
    Last Post: 09-27-2010, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums