Trouble with global variable

  • Thread starter Thread starter meilu
  • Start date Start date
M

meilu

First of all:
Happy Holidays!

Next:
This is my code:
*********************************************************
Option Compare Database
Option Explicit
Private pResponse As Integer

Public Property Get FinalResponse() As Integer
FinalResponse = pResponse
End Property
*********************************************************

When I try to compile it highlights
pResponse, and says that it's not defined. Am I missing
a basic step or something?

Or is my project just getting amazingly corrupted?!

Thx,
Meilu
 
meilu said:
First of all:
Happy Holidays!

Next:
This is my code:
*********************************************************
Option Compare Database
Option Explicit
Private pResponse As Integer

Public Property Get FinalResponse() As Integer
FinalResponse = pResponse
End Property
*********************************************************

When I try to compile it highlights
pResponse, and says that it's not defined. Am I missing
a basic step or something?

Or is my project just getting amazingly corrupted?!

Pasted into a new module, that works fine for me. Is pResponse maybe
also defined somewhere else?
 
Hi Dirk,

Thanks for taking the time to answer my post.
The code I posted actually did not give me any problems
until I added in the method below. So I removed the
method, and just put it into another class.
There have been no more problems. But I still don't know
WHY there were problems?! And I hate solving a problem
by just ignoring it~ -_-

I guess that's just the way it is when you're working
gainst a deadline...

Thanks again,
Meilu

Public Sub AddtoUnitTable(newEntry As String,
tempResponse As Integer)
Dim insertSql As String
Dim intMsgDialog As Integer
Dim strMsg1 As String
Dim strTitle As String

strTitle = "Add Unit choice to List?"
strMsg1 = "Do you want to add '" & newEntry & "' as a
new entry into your Unit list?"
intMsgDialog = vbYesNo + vbQuestion

Beep
If MsgBox(strMsg1, intMsgDialog, strTitle) = vbYes
Then
insertSql = "INSERT INTO UnitChoice( Unit )" & _
" VALUES ('" & newEntry & "')"
CurrentDb.Execute insertSql
tempResponse = acDataErrAdded
Else
tempResponse = acDataErrContinue
End If
pResponse = tempResponse
End Sub
 
Meilu said:
Hi Dirk,

Thanks for taking the time to answer my post.
The code I posted actually did not give me any problems
until I added in the method below. So I removed the
method, and just put it into another class.
There have been no more problems. But I still don't know
WHY there were problems?! And I hate solving a problem
by just ignoring it~ -_-

I guess that's just the way it is when you're working
gainst a deadline...

Thanks again,
Meilu

Public Sub AddtoUnitTable(newEntry As String,
tempResponse As Integer)
Dim insertSql As String
Dim intMsgDialog As Integer
Dim strMsg1 As String
Dim strTitle As String

strTitle = "Add Unit choice to List?"
strMsg1 = "Do you want to add '" & newEntry & "' as a
new entry into your Unit list?"
intMsgDialog = vbYesNo + vbQuestion

Beep
If MsgBox(strMsg1, intMsgDialog, strTitle) = vbYes
Then
insertSql = "INSERT INTO UnitChoice( Unit )" & _
" VALUES ('" & newEntry & "')"
CurrentDb.Execute insertSql
tempResponse = acDataErrAdded
Else
tempResponse = acDataErrContinue
End If
pResponse = tempResponse
End Sub

Again, it works fine for me, provided of course that the AddtoUnitTable
procedure is defined in the same module as pResponse. Otherwise, of
course it won't find pResponse, since the variable is declared Private.
If you had placed the procedure in the same module with the variable
definition, and you still got an error, I can only guess that something
else is going on, but I can't guess what.
 
Back
Top