By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Allowing permanent, user set variables in Access 2002

P: 92
I was wondering if there was a way to enable the user to set variables that remain set until the user changes them when desired, even after the database has been closed and the computer shutdown.

For instance, if you wanted the user to be able to specify where the Backup files were stored and not have to enter the address every time a Backup was made, similar to saving a document in Microsoft Word; once the location is set it isnt asked for unless the user wishes to.

I am aware that is a pretty loose comparison, as Word will have the original file to save over and therefore the address to save to.

I was just hoping there was a way to set the variable permanently, or at least to remember the address entered the last time and display that as the default along with a 'save' and 'browse' button.

Thanks,

NDayave
Jul 18 '07 #1
Share this Question
Share on Google+
7 Replies


Rabbit
Expert Mod 10K+
P: 12,316
When you want to save something permanently you have to write it to non-volatile media. i.e. a hard drive, floppy, etc. But more specifically a file. In your case, just write it to a table where you keep permanent variables, you can lookup and update the table as needed through code.
Jul 18 '07 #2

P: 92
When you want to save something permanently you have to write it to non-volatile media. i.e. a hard drive, floppy, etc. But more specifically a file. In your case, just write it to a table where you keep permanent variables, you can lookup and update the table as needed through code.
Yeah, thats the solution I arrived at, is there no way to change the actual code so the Variable is set there, for example:

Var1 = "C:\My Documents"

Which can be changed by the user through the Forms:

Var1 = "C:\My Documents\Backup"

without the need for the user to manually edit the code, as this would save a lot of space and would probably require less work the next time a Permanent variable is required.

Thanks for the reply,

NDayave
Jul 18 '07 #3

Rabbit
Expert Mod 10K+
P: 12,316
As far as I know, you can't change the coding through code. I think you and import code from a text file in which case you can change the text file that holds the code but that's just more convoluted than storing it in a file.
Jul 18 '07 #4

P: 92
As far as I know, you can't change the coding through code. I think you and import code from a text file in which case you can change the text file that holds the code but that's just more convoluted than storing it in a file.
Hmmm, okays thanks for your time anyway. I investigate urther, if i find an answer ill put it here.

Thanks again,

NDayave
Jul 18 '07 #5

ADezii
Expert 5K+
P: 8,599
I was wondering if there was a way to enable the user to set variables that remain set until the user changes them when desired, even after the database has been closed and the computer shutdown.

For instance, if you wanted the user to be able to specify where the Backup files were stored and not have to enter the address every time a Backup was made, similar to saving a document in Microsoft Word; once the location is set it isnt asked for unless the user wishes to.

I am aware that is a pretty loose comparison, as Word will have the original file to save over and therefore the address to save to.

I was just hoping there was a way to set the variable permanently, or at least to remember the address entered the last time and display that as the default along with a 'save' and 'browse' button.

Thanks,

NDayave
I was wondering if there was a way to enable the user to set variables that remain set until the user changes them when desired, even after the database has been closed and the computer shutdown
You can write permanent (persisting) values to the System Registry. These values can be written, edited, and retrieved at will. You do not run the risk of anyone modifying these values since they are not stored internally,
Jul 18 '07 #6

P: 92
You can write permanent (persisting) values to the System Registry. These values can be written, edited, and retrieved at will. You do not run the risk of anyone modifying these values since they are not stored internally,
How would I go about doing that? Would it involve creating a new file that would be project specific, or is it more generic than that?
Jul 19 '07 #7

ADezii
Expert 5K+
P: 8,599
How would I go about doing that? Would it involve creating a new file that would be project specific, or is it more generic than that?
This may not be exactly what you are looking for, but it is an alternative to consider as far as permanent storage goes:
Expand|Select|Wrap|Line Numbers
  1. Dim strPathToFile As String
  2.  
  3. strPathToFile = "C:\Test Directory\TestFile.txt"
  4.  
  5. 'To Save the File's Path to the System Registry. It will be saved in MyComputer\HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Test Database\Text File Location
  6. Dim strPathToFile As String
  7.  
  8. strPathToFile = "C:\Test Directory\TestFile.txt"
  9.  
  10. 'To Save the File's Path to the System Registry 
  11. SaveSetting appname:="Test Database", Section:="Text File Location", _
  12.                      Key:="Absolute File Path", setting:=strPathToFile
  13.  
  14. 'To retrieve the File's Path and assign it to a variable
  15. strPathToFile = GetSetting(appname:="Test Database", Section:="Text File Location", _
  16.                 Key:="Absolute File Path", Default:="Path not stored")
  17.  
  18. MsgBox strPathToFile 'returns C:\Test Directory\TestFile.txt
  19.  
Jul 19 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.