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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store Global Const Values in a Table...?

Status
Not open for further replies.
Oct 13, 2004
39
US
I currently have a module that has global variables set at the top.
I would like to however store these values in a table so that I can build a form for someone who does not know VB and they can go to the form and change the settings, or values of the global variables.

I would like to set the form_load to load the values of the table fields into text boxes on the form where the column titled "default" has a value of Y

Has anyone done this before? stored settings in a table? how did you access them?

I tried...

Public Const TABLENAME_PREFIX As String = Form_ControlCenter.txtConfig_tablePrefix.value

Thinking that I could capture the setting from a form that would auto load the default values, but obviously you can only declare constants as literals, not an object, or another variable.

I am interested to hear if any one has done this or has any suggestions or direction for this. It would most certainly be GREATLY APPRECIATED!!!!!!!

Thanks in advance!!
 
Remove out the "Const" and just declare a public variable as string (or whatever datatype is needed). Save Const for the values that are hard coded and do not change.

This will allow you to set and reset it based on your values in the table. You could then set up a quick subroutine that would, upon being called, read your table and set the public vars. Set up the sub to take an action var that does a "GET" or "SET" and then you can code from their to either update the records in the table or read the entries in the table (and of course set the public vars accordingly each time).
Does that help?
 
Just open your table and set the values of your global variables equal to the values of the fields within the table. Likewise, to save the global variables to a table.

Something like this:

Dim rst as ADODB.Recordset

Set rst = New ADODB.Recordset
rst.open "Select * from YourTable;",CurrentProject.Connection,adOpenForwardOnly,adLockReadOnly

glngGlobalVariable1 = rst!lngGlobalVariable1
gstrGlobalVariable2 = rst!strGlobalVariable2
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top