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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert form code to report code

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Hi Everyone,
i have the following code that I use to display x of y records for certain records in a form. I use the unbound textbox txtCardCount to display the info as the user navigates thru the form. I have a report version of the form that I use to print off but how do i convert the code to use in the report so that it also prints for every record since I have no "onCurrent" event and no recordsetclone object? Any help would be really appreciated.

thanks in advance

GPM

Public Sub CountSOCards()
Dim rst As DAO.Recordset
Dim lngBaseCount, lngRecord, lngTotalSO As Long

On Error Resume Next

Set rst = Me.RecordsetClone
rst.MoveFirst
rst.FindFirst "[SO]='" & Me.SO & "'"

lngBaseCount = rst.AbsolutePosition
lngTotalSO = DCount("UNIQID", "qryProduction", "[SO]='" & Me.SO & "'")
lngRecord = Me.CurrentRecord - lngBaseCount

'Show the result of the record count in the text box )
Me.txtCardCount = "Items on SO: " & lngRecord & " of " & lngTotalSO

Set rst = Nothing

End Sub
 
think of Reports as "write only". The report cannot accept any input. You need to have a seperate entity (form, input box etc (whivh is really just a "special" form?)) and have that set up the parameters for your form code to work with.




MichaelRed


 
Thanks for that,
Is there an alteration I could do to the code above that I could place in the "on open" event of the report that would cycle through the records and add the information to each record automatically? Do i need to add it to a bound field? I don't want the user to actually have to input anything, all I'm doing is checking the records and getting the info directly from there but i need it to be dynamic.

thanks

GPM
 
you could put similar code in the report open event. how similar is the question ... reports do not (in my doubtful recollection) support record set clone, so there would be a bit to do. on the other hand, since all of the information required is specifically available from the existing record set, it seems (at least conceptually) that you could change the record set at the source to include a count of the condition for each record and let the report do the sum of these counts.



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top