My setup is VB6 connected via an Adodc to an Access2K mdb Table.
I've got a DataGrid on the VB Form with its DataSource being the Adodc.
I've got a cmdButton on the Form for printing the selected Record of the DataGrid onto a DataReport.
The cmdButton code is:
Private Sub Command1_Click(Index As Integer)
OpenReport
End Sub
Private Sub OpenReport()
Dim rpt As GndsMaintReport 'The DataReport's name
Set rpt = New GndsMaintReport
rpt.Display Me.Adodc1.Recordset, vbModal
Set rpt = Nothing
End Sub
And I've got the following code on the DataReport:
Option Explicit
Private rsDataReport As ADODB.Recordset
Private Sub DataReport_Terminate()
If Not rsDataReport Is Nothing Then
If rsDataReport.State = adStateOpen Then rsDataReport.Close
End If
Set rsDataReport = Nothing
End Sub
Public Sub Display(rs As ADODB.Recordset, Optional vbModalType As VBRUN.FormShowConstants = vbModal)
Set rsDataReport = Nothing
Set rsDataReport = rs.Clone
rsDataReport.Filter = "GndsWorkID=" & rs.Fields("GndsWorkID").Value
Set Me.DataSource = rsDataReport
Me.Show vbModalType
End Sub
When I click the cmdButton I get this Run-Time error 3001 message:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." and the following line is highlighted when I debug the error:
rsDataReport.Filter = "GndsWorkID=" & rs.Fields("GndsWorkID").Value
GndsWorkID is one of the fields of the Access mdb Table that the Adodc is connected to.
I've used this approach many times and it's worked fine for printing the current record of a DataGrid onto a DataReport, but for some reason it's not working here. Does anyone have an idea of what I've got wrong?
Thanks in advance for any help!
I've got a DataGrid on the VB Form with its DataSource being the Adodc.
I've got a cmdButton on the Form for printing the selected Record of the DataGrid onto a DataReport.
The cmdButton code is:
Private Sub Command1_Click(Index As Integer)
OpenReport
End Sub
Private Sub OpenReport()
Dim rpt As GndsMaintReport 'The DataReport's name
Set rpt = New GndsMaintReport
rpt.Display Me.Adodc1.Recordset, vbModal
Set rpt = Nothing
End Sub
And I've got the following code on the DataReport:
Option Explicit
Private rsDataReport As ADODB.Recordset
Private Sub DataReport_Terminate()
If Not rsDataReport Is Nothing Then
If rsDataReport.State = adStateOpen Then rsDataReport.Close
End If
Set rsDataReport = Nothing
End Sub
Public Sub Display(rs As ADODB.Recordset, Optional vbModalType As VBRUN.FormShowConstants = vbModal)
Set rsDataReport = Nothing
Set rsDataReport = rs.Clone
rsDataReport.Filter = "GndsWorkID=" & rs.Fields("GndsWorkID").Value
Set Me.DataSource = rsDataReport
Me.Show vbModalType
End Sub
When I click the cmdButton I get this Run-Time error 3001 message:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." and the following line is highlighted when I debug the error:
rsDataReport.Filter = "GndsWorkID=" & rs.Fields("GndsWorkID").Value
GndsWorkID is one of the fields of the Access mdb Table that the Adodc is connected to.
I've used this approach many times and it's worked fine for printing the current record of a DataGrid onto a DataReport, but for some reason it's not working here. Does anyone have an idea of what I've got wrong?
Thanks in advance for any help!