Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Report Writer Recordset


Message #1 by Docbruce@a... on Fri, 15 Jun 2001 20:13:24
> 
You need to put all Code in the Initialize Event of the DataReport.  That 
is
> the time when the Report begins to "Bind" itself to the DataSource.  

Thanks for your help!
I was able to get it to work and discovered that I also screwed up the 
data report by referencing the wrong command object when populating the 
report fields. It also appears to be a good idea to check to see if the 
recordset for the report is open, then close it and reestablish the 
dataSource.
> 
> -----Original Message-----
> From: Docbruce@a... [mailto:Docbruce@a...]
> Sent: Saturday, June 16, 2001 9:54 AM
> To: professional vb
> Subject: [pro_vb] RE: Report Writer Recordset
> 
> 
> > Why don't you look at my Post in the other Post on VB Pro under "Data
> > Reprt".  It will tell you how to do everything.
> > 
> Thanks for your suggestion. I did try your solution and it gets around 
the 
> problem of the error "Operation not allowed when object is closed". 
> However, for some reason the data report cannot find the data in the 
> recordset. I do not understand what code goes in the DataReport. I have 
> tried 'Public rs as ADODB.recordset" (also as Private)in the 
declarations 
> section of the DataReport and set me.datasource=rs in the initialize 
> procedure of the DataReport and I still get the message 
> That "DriverSched.Type not found". Set me.datasource=rs cannot go in the 
> declarations section.
> Most likely I am just thick-headed in understanding your instructions.
> By the way, I thought my problem may be my use of the file dsn so I 
tried 
> it with a Jet connection as in your code.
> 
> Any other suggestions will be appreciated
> BD
> 
> I have tried tests to be sure the Type field is correct.
> > -----Original Message-----
> > From: Docbruce@a... [mailto:Docbruce@a...]
> > Sent: Friday, June 15, 2001 4:13 PM
> > To: professional vb
> > Subject: [pro_vb] Report Writer Recordset
> > 
> > 
> > I am trying to use report writer through a DSN file connection.
> > The basic code is:
> > Private cn As ADODB.Connection
> > Private rs As ADODB.Recordset
> > 
> > Private Sub Command1_Click()
> > Dim strsql As String
> > Set cn = New ADODB.Connection
> > cn.ConnectionString = "DSN=Transport"
> > 
> > cn.Open
> > Set rs = New ADODB.Recordset
> > rs.ActiveConnection = cn
> > strsql = "SELECT Type,DriverName,ApptDate from Driversched"
> > With rs
> >     .CursorLocation = adUseClient
> >     .LockType = adLockBatchOptimistic
> >     .Open strsql
> > End With
> > Set rs.ActiveConnection = Nothing
> > cn.Close
> > Set cn = Nothing
> > Set DataReport1.DataSource = rs
> > DataReport1.Show
> > End Sub
> > 
> > I get an error that indicates that the report cannot find the data 
fields
> > indicated in the sql string. The report window opens and I can access 
> > fields in the recordset before closing the connection.
> > I set up the filr DSN and refer to it in the data environment, set a 
> > connection command to the DriverSched table that I use to form the 
report
> > (drag from the dataenvironment window).
> > Can anyone tell me what I am doing wrong??
> > Thanks, in advance
> 

  Return to Index