Trouble with Variables

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
 
T

Tom Wickerath

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
 
V

Victor Delgadillo

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top