If it is clicked again ever? Or only if it is clicked again within the
current session?
For the former, you'd need to store a value somewhere to record the fact
that the button had been clicked, and look it up each time the form opens.
For the latter, you could use a static variable.
If it is clicked again ever? Or only if it is clicked again within the
current session?
For the former, you'd need to store a value somewhere to record the fact
that the button had been clicked, and look it up each time the form opens.
For the latter, you could use a static variable.
If ClickedAlready = True Then
MsgBox "You clicked me already since opening this form!"
Else
ClickedAlready = True
MsgBox "First time you clicked me since opening this form!"
End If
If gClickedAlready = True Then
MsgBox "You clicked me already since opening this MDB!"
Else
gClickedAlready = True
MsgBox "First time you clicked me since opening this MDB!"
End If
End Sub
The local variable 'ClickedAlready' will retain its value as long as the
form is open (because it is declared using the 'Static' keyword). The global
variable, 'gClickedAlready', defined in the standard module, will retain its
value when you close and re-open the form.
For more info, look for the VBA help topics 'Understanding the Lifetime of
Variables' and 'Understanding Scope and Visibility'.
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.