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!

Data Sharing Questions, Global Variables, Etc. 2

Status
Not open for further replies.

random75

Technical User
Apr 16, 2008
34
US
This is Access 2000. I have a form where, if I am editing an existing record, I need to capture the existing value of a control when it gets the focus (GotFocus event) and use that value moments later to perform a calculation during the BeforeUpdate event for the same control. I used a global variable to accomplish this. I got to thinking that since the calculation assigns a value to a variable during the BeforeUpdate event, that it could be a real problem if 2 people are doing this at the same time. The value of the global variable (used to calculate the BeforeUpdate variable) could actually be changed by a second user on his workstation (during his GotFocus event) before the calculation is being run for the first user. So then I got to thinking that I should just create an invisible control in the form to house this value and work with it in that manner. I have 3 questions. Concerning the inner workings of Access' handling of data.....

1) Is it in fact possible that my scenario concerning the global variable could happen?

2) Would this second approach (creating an invisible control in the form to house the value) insure that the values for the invisible control on the form never be changed by another user in the system at the same time. In other words, if 2 users are in the form at the same time on their respective workstations, does each user have his own version of the form with values which are unique to his session.

3) Is there a way to deal with this problem as it relates to global variables. Is there a technique or a programming approach that I could be using to eliminate the multiuser risk of assigning a second value to a global variable before a calculation routine that make use of its value?

Thanks for any input!!!
 
Did you try to use the OldValue property of the bound control ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV:

You are the man! I wish I could remind myself to check control property options before my mind races off into the great unknown. I am still interested in the answer to question #2. If a form is being used by 2 different workstations at the same time, is each user's form values unique to his/her session, so that an unbound form control used for calculation purposes would not be at risk for manipulation by other users while the form is in process at more than one workstation? Thanks!
 
Each workstation has its own instance of access.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
In response to your statement "each workstation has its own instance of access" would that also apply to global variables. In other words, would a global variable's value extend to all workstations accessing the database or does each session have its own value for the global variable?
 
Each workstation has its own global variables.
 
BTW you can actually test these things to prove it to yourself. Just open two instances of the same data base on the same machine. You can do something like


Public glblVar As String
Public Sub Testglobal()
MsgBox glblVar
End Sub

Then in the immediate window you can set the value of the global variable. You will see that nothing in one instance affects the other instance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top