Populate Access report using VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crissorion
    New Member
    • Apr 2010
    • 2

    Populate Access report using VBA

    I have an array of some data that i get from object, I can't get same data from query to database, so I can't just paste recordsourse to sql query.
    How can I populate the report? Now I get all the data inserted in one row in report.
    The code is somthing like:
    Code:
    set obj = new MyData
    
    do until obj.EOF
    
        me.text1.value = obj.getText1
        me.text2.value = obj.getText2
    ...
    obj.MoveNext
    loop
    Sorry for my english.
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Can you not insert your data into a temporary table, and then make the report be based on that table? Without more details on WHY you chooose to do as you do, I doubt its the best solution.

    Comment

    • robjens
      New Member
      • Apr 2010
      • 37

      #3
      I guess you could loop the object properties (like you do) and assign values to the control but then on the Details_Print event of the report.That should do it for every object in the array.

      But like TSO says, it's easier to create a temporary query (querydef) and then make the report. Also I'd suggest using a collection instead of a Array in this case.

      Comment

      • crissorion
        New Member
        • Apr 2010
        • 2

        #4
        Thanks for your reply. I'll try to use a temporary query.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Depending on your Version of Access, you can easily:
          1. Populate an ADO Recordset from the Array Data.
          2. Make the Recordset the Data Source for the Report by setting the Report's Recordset Property to the newly created ADO Recordset.

          Comment

          Working...