Reputation: 887
I am trying to create variable which would carry across all the users activities in MS Access.
So what I want to achieve is: The user opens the application and sets a region.
From that point onwards I want to be able to reference the region in my VBA commands that are triggered as the user moves between forms to limit data being displayed. How do I carry the variable through the various forms and queries or is it just a case of creating it as a parameter that is passed to each procedure as it is called?
Thanks
Upvotes: 1
Views: 341
Reputation: 11188
Konrad's answer covers most options, I just wanted to add that as you are using Access you could always create a user to region mapping table and store the data there.
Upvotes: 1
Reputation: 18585
Following article on ozgrid variables in VBA have three scoping levels:
It appears that the third one would be most relevant in the context of your request. You would define it like that:
Public SelectedRegion as Long
As an alternative approach, you may consider storing this selection in a file and reading the data from file. To introduce the relevant parts of the example available on the website:
myFile = "C:\test\geographical-coordinates.txt"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & textline
Loop
Close #1
Upvotes: 1