Jhovyn Marcos
asked on
Sub or Function is not defined
Why am I getting an error "Sub or Function is not defined"...Here is my code
Form 2
Form 1.....Call my function "printReport" here
The error message goes here "Private Sub Command1_Click()"
Form 2
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()
printReport
End Sub
The error message goes here "Private Sub Command1_Click()"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It is owing to relevant Sub or Function not matched (or put properly).
Now im getting an error "Operation is not allowed when the object is open"
That should be a new question.
That should be a new question.
ASKER
Sir @Martin Liss
I've already created new topic here https://www.experts-exchange.com/questions/29001070/Operation-is-not-allowed-when-the-object-is-open.html
Please help :(
I've already created new topic here https://www.experts-exchange.com/questions/29001070/Operation-is-not-allowed-when-the-object-is-open.html
Please help :(
I'm glad I was able to help.
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2016
Experts Exchange MVE 2015 and 2016
Experts Exchange Top Expert Visual Basic Classic 2012 to 2016
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2016
Experts Exchange MVE 2015 and 2016
Experts Exchange Top Expert Visual Basic Classic 2012 to 2016
ASKER
Thank you again sir and God Bless!