Public Variable

R

RKF

Hi Folks,

I am trying to use a public variable to control an action that I need to
perform only the first time a sub is called. (I call it twice in a
template). The sub is used to throw a calendar onto a document and allow the
user to select and date which is then posted onto the form. The first time
the sub is called and the date is posted, I reposition the pointer to a
specific bookmark. Obviously doing so the second time the sub is called
(from near the end of the template/document) does not work well as the user
still has some fields to populate beyond that second date ...

I am not having great success with setting up an If Then Else scenario to
check the initial status of the public variable, post the first date,
reposition the pointer and then skip the instruction to reposition the
pointer the second time the sub gets called...

I can provide the tempate/code should anyone feel they can assist me with
this.

Thanks,

Fergie
 
S

Steve Rindsberg

Hi Folks,

I am trying to use a public variable to control an action that I need to
perform only the first time a sub is called. (I call it twice in a
template). The sub is used to throw a calendar onto a document and allow the
user to select and date which is then posted onto the form. The first time
the sub is called and the date is posted, I reposition the pointer to a
specific bookmark. Obviously doing so the second time the sub is called
(from near the end of the template/document) does not work well as the user
still has some fields to populate beyond that second date ...

I am not having great success with setting up an If Then Else scenario to
check the initial status of the public variable, post the first date,
reposition the pointer and then skip the instruction to reposition the
pointer the second time the sub gets called...

I can provide the tempate/code should anyone feel they can assist me with
this.

A static variable might do it for you:

Sub Thing()
Static bFlag as Boolean

If not bFlag Then
' we haven't been here before so do your stuff then
bFlag = True
End If

End Sub
 

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