By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

Populate Access report using VBA

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. set obj = new MyData
  3.  
  4. do until obj.EOF
  5.  
  6.     me.text1.value = obj.getText1
  7.     me.text2.value = obj.getText2
  8. ...
  9. obj.MoveNext
  10. loop
  11.  
  12.  
Sorry for my english.
Apr 22 '10 #1

✓ answered by robjens

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.

Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
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.
Apr 23 '10 #2

P: 37
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.
Apr 23 '10 #3

P: 2
Thanks for your reply. I'll try to use a temporary query.
Apr 23 '10 #4

ADezii
Expert 5K+
P: 8,597
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.
Apr 23 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.