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

Placing Fields without a DB connection?

Status
Not open for further replies.

zakman

Programmer
Aug 15, 2001
49
US
Is there any way to place field objects on a report without having a
database connection beforehand?

I have one report that I wish to use with multiple recordsets
that are generated within Visual Basic. I do not wish to assign the
database connection within CR, but rather wait until I'm ready to
open the report in VB.

Right now I am having to use unbound field boxes and also have to
use the .SetUnboundFieldSource method on each box after assigning
the ADO recordset to the report. A royal pain in the butt!

Any suggestions are appreciated!
Z

 
Yes it is very easy to do that
I am giving an example with will help u too much
but ur report datafields and recordset fields must be same

'here is the Code

'ADD the to a Module in VB
Declare Function CreateReportOnRuntimeDS Lib "p2smon.dll" ( _
lpUnk As Object, ByVal ReportFile As String, ByVal FieldDefFile _
As String, ByVal bOverWriteFile As Long, ByVal bLaunchDesigner _
As Long) As Long

Public Function CreateReportOnRuntime(ByRef Rs As RecordSet, _
ByVal ReportFile As String, ByVal FieldDefFile _
As String, Optional ByVal bOverWriteFile As Boolean = True) As Long

CreateReportOnRuntime = CreateReportOnRuntimeDS(Rs, ReportFile, FieldDefFile, bOverWriteFile, 0)
End Function

*********
ADD this code to Form
also add a CRViewer control to another Form 'frmViewReport'
public sub viewreport()
'call this function 'CreateReportOnRuntime' once just to create a report and DatadEFINITIONfILE

Result = CreateReportOnRuntime(m_oRs, App.Path & "\" & m_ReportName & ".rpt", _
m_ReportName & ".ttx", True)
Set m_oRpt = m_oApp.OpenReport(App.Path & "\" & m_ReportName & ".rpt")


With frmViewReport
m_oRpt.PaperOrientation = m_ReportOreintation
m_oRpt.DiscardSavedData
m_oRpt.Database.SetDataSource m_oRs, 3, 1
.CRViewer.ReportSource = m_oRpt
.CRViewer.Zoom 1
.CRViewer.ViewReport
End With
Exit Sub

end sub
Riaz Afridi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top