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!

PRINT CURRENT RECORD NOT WORKING WHEN I COPY FORM TO NEW PRJ FOLDER 1

Status
Not open for further replies.

Hiccup

Programmer
Jan 15, 2003
266
US
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!
 
Your project needs a reference to Microsoft ActiveX Data Objects 2.X

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thanks johnwm, all I had to do (per your suggestion) was to add the Microsoft ActiveX Data Objest Recordset (Project>References) and the the form in the new Project Folder prints fine now.

Here's a star for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top