473,507 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sub or Function is not defined

2 New Member
Why am I getting an error "Sub or Function is not defined"...Here is my code
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Public Report As New CrystalReport1
  3. Public mvCn As New ADODB.Connection
  4.  
  5.      Public Function printReport()
  6.  
  7.      Dim strConnectionString As String
  8.      Dim rs As ADODB.Recordset
  9.      Dim strScript As String
  10.  
  11.      strConnectionString = "Provider=SQLOLEDB............"
  12.  
  13.      mvCn.ConnectionString = strConnectionString
  14.      mvCn.CommandTimeout = 0
  15.      mvCn.CursorLocation = adUseClient
  16.      mvCn.Open
  17.  
  18.      strScript = strScript & "SELECT * FROM employee" & vbCrLf
  19.  
  20.      Set rs = mvCn.Execute(strScript)
  21.  
  22.      Report.Database.SetDataSource rs
  23.      Report.AutoSetUnboundFieldSource crBMTNameAndValue
  24.  
  25.      CRViewer1.ReportSource = Report
  26.      CRViewer1.ViewReport
  27.  
  28.      Set Report = Nothing
  29.  
  30.      End Function
Form 1.....Call my function "printReport" here
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4.  
  5. printReport
  6.  
  7. End Sub
The error message goes here "Private Sub Command1_Click()"
Feb 8 '17 #1
2 1244
PhilOfWalton
1,430 Recognized Expert Top Contributor
I'm guessing.

1 Try Call PrintReport in your Sub Command1_Click

2 Are there any controls on your form called "PrintReport"?

Phil
Feb 8 '17 #2
jhovyn
2 New Member
Oh I forgot something..My printReport Function is defined in "Form2"
Feb 9 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2405
by: Andrew Boothman | last post by:
Hi, This may be the dumbest question ever, but in the following code (using PHP 4.3.8) how do I call b() from within a()? class test { function a() { print "a called"; b();
3
20627
by: lallous | last post by:
Usually you can check for a defined variable as: #ifdef DEF1 // do stuff here #endif Can I test if a function is defined then do things, example: int myFnc() { // blah blah }
5
12160
by: rashmi | last post by:
how to use static function defined in one file in another file is that impposiible in 'c '
12
1782
by: jeniffer | last post by:
Can a static function defined in a C file be ever referred (called) externally from another C file?If so in which conditions?
19
3802
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
6
30010
by: silverburgh.meryl | last post by:
Hi, I have a function called 'test' defined in A.py. How can I call that function test in my another file B.py? Thank you.
2
1671
by: yawnmoth | last post by:
Say I have the following: <script> var cat = (function() { var name = ""; function changeName(name) { this.name = name; }
22
3955
by: thekingsnake | last post by:
After following the instructions from the answer below: http://bytes.com/topic/javascript/answers/153274-script-iframe-can-not-call-functions-defined-parent-document I was able to have the...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.