Results 1 to 3 of 3
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Setting a Report Variable with a string

    Before I open a report I want to run the record source query to see how many records are in it. How do I set the value of my report variable based solely on the name of the report selected on my form? This does not work. Error 424 - Object Required




    Code:
    dim rptName As Report
    set rptName = "Reports!" & Me.cboReport.Column(2)
    qryName = rptName.RecordSource
    Any suggestions?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    qryName = Reports(rptName).RecordSource

    However, report must be open in order to reference its RecordSource property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks June,

    This is what I came up with.

    Code:
            
            rptName = Me.cboReport.Column(2)
            DoCmd.OpenReport rptName, acViewDesign
            Reports(rptName).Visible = False
            qryName = Reports(rptName).RecordSource
            
            DoCmd.Close acReport, rptName, acSaveNo

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

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  2. Setting Variable Default for Combo Box
    By gazaway in forum Forms
    Replies: 5
    Last Post: 04-08-2013, 10:32 AM
  3. Setting SQL = string
    By jasonbarnes in forum Programming
    Replies: 7
    Last Post: 02-18-2011, 11:02 AM
  4. Setting Temporary Variable
    By KEVWB in forum Access
    Replies: 1
    Last Post: 02-07-2011, 01:41 PM
  5. Replies: 3
    Last Post: 10-09-2010, 11:53 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