Results 1 to 3 of 3
  1. #1
    dj59 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    13

    Insert value of an loop array item into a report.

    I have a report with an unbound text field named txtCtyName.


    My vba code loops through an array and exports a report.
    I want to write the code so that before it exports the report, it fills in txtCtyName, with the value of the array item.

    The items in the array = x

    I want to do something like this, but am not sure how to write the part that is in Red.

    Code:
    'if the array item x = 02 then
    If x = "02" Then
    'open the report
    DoCmd.OpenReport "Report_65"
    'Insert x (or '02') into the txtCtyName field on the report
    txtCtyName = x
    'Close report....and then I would go on to export it....
    DoCmd.Close
    
    MsgBox "check it now"
    End If
    Thanks for any help or direction on this

  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,815
    There are several methods to pass a value to a report and populate a textbox but I don't really understand what you are trying to accomplish.

    Why is an array involved?

    Does only one name need to be passed to report?

    Why is the city name not in the report RecordSource?
    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
    dj59 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    13
    Thank you based on the keywords you used, I was able to find what I needed.
    The following works well.
    Code:
    'if the array item x = 02 then
    If x = "02" Then
    'open the report
    DoCmd.OpenReport "Report_65"
    'Insert x (or '02') into the txtCtyName field on the report
    Reports![Report_65]![txtCtyName].Value = x
    'Close report....and then I would go on to export it....
    DoCmd.Close
    
    MsgBox "check it now"
    End If

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

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2014, 07:43 AM
  2. Replies: 5
    Last Post: 12-21-2013, 06:26 PM
  3. Loop or Array not recognized
    By dvgef2 in forum Forms
    Replies: 6
    Last Post: 05-31-2013, 08:37 AM
  4. Printing an Array at End of Report
    By EddieN1 in forum Reports
    Replies: 4
    Last Post: 05-12-2013, 11:19 AM
  5. Replies: 30
    Last Post: 08-30-2012, 05:14 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