Link to home
Start Free TrialLog in
Avatar of edh-home
edh-home

asked on

GetSetting/SaveSetting

Hi all

I'm trying to use GetSetting and SaveSetting to retreive and store data.  I'm having an issue with GetSetting.

WHat I'm trying to do is allow users to save some options from my database to the registry.  I want to be able to have some default settings before they ever open the database and then I want them to be able to change them and store them.  I was thinking of creating all the registry keys I need and then have them imported into the user's registry automatically when they download my database from our local intranet.  Getting the keys out there isnt an issue, but I wanted to give some background.

So far, as a test on my PC, I've created a the following registry entries...
-------------------------------------------------------------------------------------------------------------
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\AWG2007]

[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\AWG2007\Application]
"AppName"="AuditWizard GUI 2007"
"LocalVersion"="3.3.0.2"
"LastRevision"="10/23/2006"
"Maximize"="-1"
"ShowToolsMenu"="0"
"ScreenResolution"=""

[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\AWG2007\Options]
"AutoUpdate_On/Off"="0"
"AutoUpdate_Type"=""
"Location_Database"=""
"Location_Save"=""
"Location_Backup"=""
"Filter_InstalledSoftware"="0"
"UpdateCountsEnabled"="0"
"UpdateCountsTime"=""
"RefreshDatabaseEnabled"="0"
"RefreshDatabaseTime"=""
"ShowTimers"="0"
-------------------------------------------------------------------------------------------------------------

I have a form (frmOptions) with controls for each registry key.  The first control I've been working with as a test has been txtDBLocation.  This textbox will show the value of the key "Location_Database".  The user can also enter text into this textbox to update the registry key value.  What I've done to test this is set the following code in the OnOpen event of the frmOptions form.
-------------------------
Private Sub Form_Open(Cancel As Integer)
     Dim strDBLOCdef As String
     strDefault = Environ("userprofile") & "\desktop\"
     Me.txtDBLocation.Value = GetSetting("AWG2007", "Options", "Location_Database", strDefault)
End Sub
-------------------------
This work fine if there is a value stored in the Location_Database key, but if the value is blank nothing gets put into the textbox (no matter if set a default value in the GetSetting string).  Also, instead of using the Environ string I tried a simple "test" as the default value and this didnt work either....

Any thoughts on this?
Thanks
Avatar of edh-home
edh-home

ASKER

correction to above: Dim strDBLOCdef As String is actually strDefault
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That works, but I thought the whole point of the default value was so that you didn't have to do an IF statement.  Am I wrong?