Trouble with Variables

  • Thread starter Thread starter Meilu
  • Start date Start date
M

Meilu

I am suffering from a VERY IDIOTIC problem...

I am coding in VB, I declare a variable ... either
global or in a parameter ... and it is not recognize when
I compile!
Example 1:
Option Compare Database
Option Explicit
Private cInfo As String
Private comInfo As String

Public Property Get ContactInfo() As String
ContactInfo = cInfo
End Property

Problem: cInfo NOT declared!

Exampled 2:
Public Sub PullContactInfo(eType As String, eName As
String, openForm As Boolean, Optional cName As Variant)
Dim stDocName As String
Dim stLinkCriteria As String
Dim EntityType As String
Dim EntityName As String

EntityType = eType
EntityName = eName

stDocName = "Contact Information"
'Debug.Print eType
'Debug.Print eName
stLinkCriteria = "[EntityType]=" & "'" & eType
& "'" _
& "AND [EntityName]=" & "'" &
eName & "'"

.....

Problem: stLinkCriteria not defined/declared. OR
eType/eName not declared.

I really don't want to have to restart ... cause this is
A LOT OF WORK... but at the same time ... I can't imagine
any other solution!

Any idea on why this is happening?

Meilu
 
Are you working in VB (Visual Basic)? If so, you should post your question to the
appropriate newsgroup.

Your code compiles fine in my Access 2002 VBA environment.


_______________________________________

I am suffering from a VERY IDIOTIC problem...

I am coding in VB, I declare a variable ... either
global or in a parameter ... and it is not recognize when
I compile!

Example 1:
Option Compare Database
Option Explicit
Private cInfo As String
Private comInfo As String

Public Property Get ContactInfo() As String
ContactInfo = cInfo
End Property

Problem: cInfo NOT declared!

Exampled 2:
Public Sub PullContactInfo(eType As String, eName As
String, openForm As Boolean, Optional cName As Variant)
Dim stDocName As String
Dim stLinkCriteria As String
Dim EntityType As String
Dim EntityName As String

EntityType = eType
EntityName = eName

stDocName = "Contact Information"
'Debug.Print eType
'Debug.Print eName
stLinkCriteria = "[EntityType]=" & "'" & eType
& "'" _
& "AND [EntityName]=" & "'" &
eName & "'"

.....

Problem: stLinkCriteria not defined/declared. OR
eType/eName not declared.

I really don't want to have to restart ... cause this is
A LOT OF WORK... but at the same time ... I can't imagine
any other solution!

Any idea on why this is happening?

Meilu
 
This is the Access news, but by just looking at your definition, you should
either declare your cInfo as Global at the top of the module:
Option Compare Database
Option Explicit
Global cInfo as String
Global comInfo as String

Public Function GetContactInfo() as String
GetContactInfo = cInfo
End Function

So, you must set the value of cInfo elsewhere before being able to call
GetContactInfo.
You are calling it Property, there are only two types of procedures:
Functions and Subs.
In your case, it would be a function, not a property.

Global can be substitute for public: Public cInfo as String....
Never declare private on the module level... it gets lost.
 
Back
Top