Results 1 to 7 of 7
  1. #1
    Frank F is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2020
    Posts
    3

    Question How to add a variable field on a report which gets its value from an unrelated query?

    How can I provide a single field on a report that gets its value from another query which has no link to the report's main query/table? The standalone query simply provides a value I wish to display on the report, in addition to the report's own data. Because I can't "join" the two queries (no common key fields), I keep getting an outer join error message.


    The report lists dated transactions grouped by client. That part works fine. But I also want to show the earliest (Minimum) date of ALL transactions (regardless of client). The main query provides the clients' data. The secondary query simply provides the single earliest transaction date (of ALL transactions) -- it has no "key" for joining to the clients' data. It's simply a single record/single field dataset. But I want this date to appear with every client's group. Its value would be identical for all clients. It's a variable, because it depends on the minimum date value for all transactions in a table of transactions, which could differ whenever the report is run.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try a textbox with:

    =DLookup("FieldName", "QueryName")

    replacing the names as appropriate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    add the field to the query: "bob" as MyField

  4. #4
    Frank F is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2020
    Posts
    3

    Getting unrelated data for a report

    Quote Originally Posted by pbaldy View Post
    Try a textbox with:

    =DLookup("FieldName", "QueryName")

    replacing the names as appropriate.

    Thanks for your quick reply! However, I'm still having a problem, keep getting "#Error" result. I've tried several variations of DLookup with and without double quotes. Also tried DMin to see if I could get the value I wanted directly from the table, but same result. Further suggestions?! (I'm new to Access).

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Hard to help without seeing exactly what you tried. The query/table and field names must be spelled correctly of course, and the quotes need to be there. A DMin() could certainly let you skip the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Frank F is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2020
    Posts
    3
    Found the problem. I had the quotes inside the brackets, not outside! So control =Dmin("[XtnDate]", "[XtnTable]") worked perfectly. Many thanks, Paul, for your assistance!! Quite a learning curve to Access. I've been taking the tutorials on Lynda.com which are very good. Just need more practice. I also work with FileMaker on an iMac, so it's easy to confuse the two. - Frank F.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it sorted Frank!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. add a new (unrelated) table to my report
    By Serhii in forum Reports
    Replies: 3
    Last Post: 11-14-2019, 10:44 AM
  2. Replies: 1
    Last Post: 07-08-2015, 11:00 AM
  3. Replies: 2
    Last Post: 06-19-2013, 06:13 AM
  4. binding report field to variable
    By frente in forum Reports
    Replies: 1
    Last Post: 10-19-2009, 02:48 AM
  5. Replies: 1
    Last Post: 07-07-2009, 01:00 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