Jhovyn 0 Newbie Poster

Why am I getting an error "Operation is not allowed when the object is open"....Here is my code

Option Explicit
Public Report As New CrystalReport1
Public mvCn As New ADODB.Connection

Public Function printReport()
Dim strConnectionString As String
Dim rs As ADODB.Recordset
Dim strScript As String
strConnectionString = "Provider=SQLOLEDB............"

mvCn.ConnectionString = strConnectionString
mvCn.CommandTimeout = 0
mvCn.CursorLocation = adUseClient
mvCn.Open

strScript = strScript & "SELECT * FROM employee" & vbCrLf

Set rs = mvCn.Execute(strScript)

Report.Database.SetDataSource rs
Report.AutoSetUnboundFieldSource crBMTNameAndValue

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

Set Report = Nothing

End Function

Form 1.....Call my function "printReport" here

Option Explicit
Private Sub Command1_Click()
Form2.printReport
End Sub

Im getting error here

mvCn.ConnectionString = strConnectionString