My setup is VB6/Access2k. I have a Form with a DataGrid, which is connected to the Access mdb Table via an Adodc.
Tek-Tips member. CCLINT gave me the following code (which works fine) to print the currently selected record of the DataGrid onto a VB DataReport.
The code I have on the DataReport is:
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 = "Employee_ID='" & rs.Fields("Employee_ID").Value & "'"
Set Me.DataSource = rsDataReport
Me.Show vbModalType
End Sub
And the code I have on the cmdButton which prints the DataReport is:
Private Sub cmdPrintRecord_Click()
OpenReport1
End Sub
Private Sub OpenReport1()
Dim rpt As EmployeeReport
Set rpt = New EmployeeReport
rpt.Display Me.Adodc1.Recordset, vbModal
Set rpt = Nothing
End Sub
The above works fine, but I want to use the Form in a new VB Project, so I've copied and pasted the Form into a new VB Project File Folder and created a new DataReport and added the exact same code as above to the new DataReport. I've changed the path of the Adodc on the Form to the Access mdb contained in the new Project folder (the mdb in the new folder has the same Table name and Field names as the original mdb). When I try to run the new Project I get the following complie error:
"User defined type not defined" and the following is highlighted:
rsDataReport As ADODB.Recordset
Anyone know what I'm not defining (or doing wrong) in the new Project?
Thanks in advance!
Tek-Tips member. CCLINT gave me the following code (which works fine) to print the currently selected record of the DataGrid onto a VB DataReport.
The code I have on the DataReport is:
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 = "Employee_ID='" & rs.Fields("Employee_ID").Value & "'"
Set Me.DataSource = rsDataReport
Me.Show vbModalType
End Sub
And the code I have on the cmdButton which prints the DataReport is:
Private Sub cmdPrintRecord_Click()
OpenReport1
End Sub
Private Sub OpenReport1()
Dim rpt As EmployeeReport
Set rpt = New EmployeeReport
rpt.Display Me.Adodc1.Recordset, vbModal
Set rpt = Nothing
End Sub
The above works fine, but I want to use the Form in a new VB Project, so I've copied and pasted the Form into a new VB Project File Folder and created a new DataReport and added the exact same code as above to the new DataReport. I've changed the path of the Adodc on the Form to the Access mdb contained in the new Project folder (the mdb in the new folder has the same Table name and Field names as the original mdb). When I try to run the new Project I get the following complie error:
"User defined type not defined" and the following is highlighted:
rsDataReport As ADODB.Recordset
Anyone know what I'm not defining (or doing wrong) in the new Project?
Thanks in advance!