Results 1 to 3 of 3
  1. #1
    Rick_S. is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Location
    San Antonio, TX
    Posts
    8

    How to capture value of a field from parameter driven query

    Hi folks,



    New account & first post... so please bear with me.

    I have a parameter driven query that will always return at least one line of output. The goal is to export the queried data to an Excel spreadsheet. So far, everything I've described works just fine.

    The problem is in naming the newly exported Excel file. I would like to use the value of two fields in the query to build a file name. It does not matter which row from the query the values come from as the values are all the same for any given execution of the query.

    The first of the two fields is named "ORG"; is of string type and always has 3 characters and is the left most column in the results.

    The second of the two fields is named "Campus_Dept" and always has 10 or more characters and is the 2nd column in the results.

    I run the query with a DoCmd.OpenQuery, but have been unsuccessful in capturing the two values needed. I tried a DLookup, but got an error message: "Run-time error '3326 This Recordset is not updateable."

    Any and all help greatly appreciated.

    Hope all is well & till later,
    Rick S.
    San Antonio, TX

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you show us the code for the DLookup() that you used.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Rick_S. is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Location
    San Antonio, TX
    Posts
    8
    Hi again,

    m_org = DLookup("[ORG]", "Q_Individual_ORG_Detail_Parameter")

    m_org is a local variable used later to name the exported spreadsheet

    [ORG] is a field returned by the query

    Q_Individual_ORG_Detail_Parameter is the name of the parameter driven query

    I've omitted the optional "Where" clause as all the ORG values are the same; actually tried with and w/out the "Where", but the results were the same.

    Thoughts ?

    Many thanks & till later,
    Rick S.

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

Similar Threads

  1. Date Driven If statement in VBA
    By OverPlayed in forum Modules
    Replies: 4
    Last Post: 03-01-2018, 03:03 PM
  2. Capture Value From Text Field
    By jo15765 in forum Forms
    Replies: 3
    Last Post: 03-15-2017, 06:54 PM
  3. use parameter in field name of select query
    By focosi in forum Queries
    Replies: 2
    Last Post: 02-11-2012, 10:34 AM
  4. Parameter query on memo field?
    By UnfinishedStory in forum Queries
    Replies: 1
    Last Post: 10-27-2011, 11:05 AM
  5. Problem with parameter driven combo box
    By clydet2 in forum Queries
    Replies: 0
    Last Post: 04-06-2009, 12:19 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