Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report with Unbound Controls

Status
Not open for further replies.
Joined
Sep 1, 1999
Messages
7
Location
US
I am working on a report with unbound controls (as my data source field names are dynamic).&nbsp;&nbsp;I created the report with the required number of bound controls and have written the appropriate code to open the required record set.<br><br>The problem I have is that the code loops through the entire record set but the report shows only the last record in the record set.&nbsp;&nbsp;<br><br>Could some one please tell me how I can make the report show all the records in the recordset?<br><br>Thanks very much for your time. I am attaching the portioof the code that I use to populate the report controls.<br><br>Thanks.<br><br>Prasad<br>---------------------------------------------------------<br><br>Code<br>------------------------------------------------ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>rstReport.MoveFirst<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;Do While Not rstReport.EOF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>For intX = 1 To 24<br>' fill in Standard Values<br>&nbsp;Me(&quot;Value&quot; + Format(intX)) = rstReport(intX - 1)<br>&nbsp;Debug.Print &quot;intX, Value/Result&quot;; intX, Me(&quot;Value&quot; + Format(intX)), rstReport(intX - 1)<br>Next intX<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>'&nbsp;&nbsp;Move to next record in recordset.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>Debug.Print &quot;Record position:&quot;, rstReport.AbsolutePosition<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>rstReport.MoveNext<br><br>Loop
 
Prasad,<br><br>I assume you are putting this code in the detail's on format or on print event.&nbsp;&nbsp;This means that each time you display the detail section, you cycle through the entire recordset, setting the unbound control.&nbsp;&nbsp;This unbound control will only get the data from the last recordset because you are writing over the previous records.&nbsp;&nbsp;<br><br>What you need to do is open the recordset in the report's on open event and close it in the on close event or when the last record is reached.&nbsp;&nbsp;In the On Format or On Print event for the detail section, you assign the unbound controls, and if there are more records, move to the next record.&nbsp;&nbsp;There will be no looping needed, and I assume the recordset contains the same number of records as the query that runs the report.<br><br>Give this a try.<br><br>-Chopper<br><A HREF="mailto:Kenneth.Mai@exch.compass-usa.com">Kenneth.Mai@exch.compass-usa.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top