Results 1 to 5 of 5
  1. #1
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305

    Refer to a report field value in VBA

    Basically, I'm trying to have VBA create a Windows folder named off the value of a report's field. I'm not certain how to reference a report's field value in VBA though. Any suggestions?

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Don't (you can't if the report is not open anyway), use instead the control source of the report's control in a dLookup:
    MyFolder=Dlookup("ControlSource","ReportRecordSour ceQuery")

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I'm not certain how to reference a report's field value in VBA though.
    Same method as you would do for a form.
    If your field is a repeating field in the report, you're going to need to add criteria to that. Took me a moment to figure out what happened to the suggestion, so here it is without the extra space:
    Code:
    MyFolder=Dlookup("ControlSource","ReportRecordSourceQuery")
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Thanks Micron, that's way we should always use the code tags.... guilty as charged
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    TBH I often forego them for a couple of short lines, but I've long been aware of the 50(ish) character break so I watch out for that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. How can I refer to field names using a variable
    By Tony Franks in forum Programming
    Replies: 3
    Last Post: 06-06-2016, 10:05 AM
  2. formula refer to header field
    By poire in forum Database Design
    Replies: 3
    Last Post: 06-02-2012, 08:22 PM
  3. Replies: 4
    Last Post: 02-16-2012, 05:23 PM
  4. Replies: 10
    Last Post: 08-08-2011, 01:55 PM
  5. Replies: 1
    Last Post: 04-15-2011, 01:43 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