Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA MODULE Question`

Status
Not open for further replies.

novice24

Technical User
Jun 20, 2001
17
US
To anyone,

Within a module while it is running, is there any way to assign a value to a public variable. NOT before the function begins or after it ends. But at a chosen spot within the processing of the code of the module.

Is it done with a tag or bookmark or something else. Any example would be appreciated.

thanks
 
Public lngAnswer as Long

Public Function SquareSomeValue(lngValueToSquare as Long)
lngAnswer = lngValueToSquare * lngValueToSquare
End Function
'after calling the function and passing it something like 4 then lngAnswer will hold the value 16. Is that what you are looking for?
 
DrJavaJoe-Not Really, but it is my own confusion that is hurting. Let me try again.

***********************************************************

Private Sub Form_Load()
Call XXX
end sub

***********************************************************

Public Sub XXX

if [Forms]![main]![text8] = "GO" then
'do something'
else
end if

****** HERE ASSIGN A VALUE TO A Public Variable ****** After the above If statement is evaluated and before the below If statement is started
***********************************************************

if [Forms![main2]![text1] = "Stop" then
'do something'
else
end if

end sub

***********************************************************
Basically, trying to set a value at a certain point in the execution of a called function. Is it possible.
 
Option Explicit

Public Var As String

***********************************************************

Private Sub Form_Load()
Call XXX
End Sub

***********************************************************

Public Sub XXX()

If [Forms]![main]![text8] = "GO" Then
'do something'
Else
End If

****** HERE ASSIGN A VALUE TO A Public Variable ****** After the above If statement is evaluated and before the below If statement is started
***********************************************************
Var = "whatever you want"

if [Forms![main2]![text1] = "Stop" then
'do something'
Else
End If

End Sub

***********************************************************
 
what about that then?


***********************************************************

Private Sub Form_Load()
Call XXX
end sub

***********************************************************

Public Sub XXX

if [Forms]![main]![text8] = "GO" then
'do something'
else
end if

publicVar = someValue

if [Forms![main2]![text1] = "Stop" then
'do something'
else
end if

end sub

***********************************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top