Use Tag property to load a string into a Text Box

  • Thread starter Thread starter Bradley C. Hammerstrom
  • Start date Start date
B

Bradley C. Hammerstrom

A2K,

Here's a simple one I can't get to work.

On a form, the cmdBrowse button displays the chosen destination folder path
in txtFolderName. The user then clicks cmdGO button to call a function that
uses the path in txtFolderName. The user then closes the form.

I want the same folder path to appear next time the form is opened, so the
user doesn't have to Browse again.

I tried a line of code in the On_Click event of cmdGO that stores the string
in the Tag, like:

cmdOK.tag = txtFolderName

Then a line in the Load event for the Form to paste the Tag, like:

txtFolderName = cmdOK.tag

The string correctly appears in the cmdOK Tag line in the Properties box,
but when I open the form again the txtFolderName box is blank. What's going
wrong?

Brad H.
 
Hi Bradley,

Run-time changes to forms are not saved. Better to store "user settings"
like this in a table where data's meant to be kept<g>.

Set up a little table along these lines:

tblSettings
SettingName - Text (32 charcters max) - Primary key
SettingValue - Text (255)

and create a record with SettingName = "DefaultOutputFolder" or some
such.

Then store the new value with something like

DBEngine(0)(0).Execute "UPDATE tblSettings SET SettingValue=""" _
& Me.txtFolderName.Value _
& """ WHERE SettingName=""DefaultOutputFolder"";"

and retrieve it with something like
Me.txtFOlderName.Value = DLookup("SettingValue", tblSettings, _
"SettingName=""DefaultOutputFolder""")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top