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

Passing a Parameter to an ADO

Status
Not open for further replies.

rier

Technical User
Sep 13, 2000
27
GB
Can anyone help?

I have an SQL script which I am connecting to using the ADO method. What I want to do is to be able to enter a date range via a Parameter and parse this to the sql script,

Does anyone know how to achieve this?

Thanks

Richard
 
Ok here's how I did it,

Dim Report As New CrystalReport1
Dim rptCNN As New ADODB.Connection
Dim rptRS as New ADODB.Recordset

Private Sub Form Load()

Set rptCNN = New ADODB.Connection
Set rptRS = New ADODB.Recordset

rptCNN.Open "your connection details go in here"

rptRS.Open &quot;SELECT * FROM yourtable WHERE Date >= &quot; & yourmindate & &quot; AND Date <= &quot; & yourmaxdate, rptCNN

Screen.MousePointer = vbHourGlass
Report.Database.SetDataSource rptRS
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Resize
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub

Private Sub Form_Unload(Cancel As Integer)
'kill instances created

Set Report = Nothing
rptRS.Close
Set rptRS = Nothing
rptCNN.CLose
Set rptCNN = nothing

End Sub
 
Thanks Snedwan, but a little too involved - I basically have a sql script I call from CR using an ADO connection and I just want to be able to pass a date range

Anyone else know how to go about this?


Thanks

Richard
 
In this coding scriptout of range error is evaluated.please give some ideas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top