Saving Public Variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have set up a Public Variable in a module called trees like this

Public Book As String

That I use at various times on different forms during the use of the
database to store a piece of text the user as input earlier.
Is there a way that I can save it so that the next time I open up the
database it is still using the same piece of text without putting it into a
table?

David
 
David said:
I have set up a Public Variable in a module called trees like this

Public Book As String

That I use at various times on different forms during the use of the
database to store a piece of text the user as input earlier.
Is there a way that I can save it so that the next time I open up the
database it is still using the same piece of text without putting it into a
table?

David

No. your only other option, AFAIK, is to use a custom property, which
is essentially a table with a single entry. And then you need DAO to
get to it
 
David said:
Is there a way that I can save it so that the next time I open up the
database it is still using the same piece of text without putting it into a
table?

You can create a custom database property and save the text to this property
when the user inputs it. Have a startup form's code read the property and
set the Book variable while initializing your app.
 
In addition to a custom property, you could write the text to a .ini file, or
even write the value to the registry using the GetSetting / SaveSetting
methods:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_tentipsvba.asp

or using a more advanced method:

How To Use the Registry API to Save and Retrieve Setting
http://support.microsoft.com/kb/145679


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
David said:
How do I call that custom database property in vbscript?

Access doesn't use VB Script, hon. It uses VBA, Visual Basic for
Applications. You need to create the custom database property first like
this:

Set prp = CurrentDb.CreateProperty("Secret", dbText, "Area51", False)
CurrentDb.Properties.Append prp

Later, when you need to set the property:

CurrentDb.Properties("Secret") = "UFO Landing Zone"

When you need to read the property:

var = CurrentDb.Properties("Secret")
 
Back
Top