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

Report/Data Report 1

Status
Not open for further replies.

SmokinWrek

IS-IT--Management
Jun 20, 2002
36
0
0
US
I need help!

I have a program that reads in a flat datafile (fixed field/record length) and rewrites that file, but with extra records inserted every so often. The interval of insertion is dependant upon user input at the start of the program. I need to create a report that is based on the information being put into these extra records as well as information generated based on user input at the start of the program.

I would like to do a data report so that future revisions are relatively easy, but unsure as to how to provide the datasource. I've thought about using a data-aware class as the datasource, is this possible? If so, how would I go about getting the data that's being generated in my program into the recordset of the data-aware class? Would I have to write this data as records to a file before I could create the report?

I'm fairly new to classes as well as ADO, so an explanation rather than (or in addition to) code would be most appreciated.

Kevin
 
Kevin,

You could use a disconnected ADO recordset as your datasource. Here is an example:

' Declare the disconnected recordset and initialize it
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.Fields.Append "NumOfInputRecords", adVarNumeric, 12
.Fields.Append "NumOfOutputRecords", adVarNumeric, 12
.Fields.Append "NumOfExtraRecords", adVarNumeric, 12
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open
End With

' Add data to recordset
With rs
.AddNew
.Fields("NumOfInputRecords") = InputCount
.Fields("NumOfOutputputRecords") = OutputCount
.Fields("NumOfExtraRecords") = ExtraCount
.Update
End With

' Set rs as the datareport's datasource
Set drYOURDATAREPORTNAME.DataSource = Rs
drYOURDATAREPORTNAME.WindowState = vbMaximized
drYOURDATAREPORTNAME.Show vbModal

' Close recordset and destroy any objects
rs.Close
Set rs = Nothing


Also, make sure to add a reference to Microsoft ActiveX Data Objects X.X Library.


Swi
 
Swi,

That's along the lines I was thinking, but how do I do the design of the report without a connected datasource?

FYI, this is for a BoxHeader/Sheets program I'm developing. However, they want the full name and zip of the first and last record of each box printed on the sheet along with the box number:

Box 1 Beginning Name ZIP Ending Name ZIP
Box 2 ...

Kevin
 
Instead of typing all of it I will send a zip file of a demonstration that I originally created for Matt N. You should see it in your Yahoo email soon.

Swi
 
Thanks, Swi! I was under the impression (from the help files) that I had to have an active connection during design time to assign the DataFields.


Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top