Hi fernandez,
sorry for my delay I forgot this thread. There is an example.
In my application I have a hidden table that I use for storing everything. The table has the folloving fields:
Variable (text) - variable name
Category (text) - in order to use the same names of variables in different circumstances
Value (memo) - value of the variable, type memo because of long strings
Type (number) - VBA constants defining the type of variable
e.g. vbInteger, vbDate etc.
Primary key is set on Variable and Category
Next I have two function for saving and reading the variables.
Please be aware that the function setVariable doesn't work for linked table. In that case you should use method FindFirst instead of Seek.
Public Function setVariable(acVariableName As String, vVariable As Variant, Optional acVariableCategory _
As String = "General", Optional nVariableType As Integer = -1) As Integer
' Code Header inserted by the Procedure Header Add-In
'=============================================================
' AppGlobal.setVariable
' Function creates new or modifies an existing variable
'-------------------------------------------------------------
' Parameters:
'-----------
' acVariableName (String) Name of variable
' vVariable (Variant) Value
' acVariableCategory (String) Category
nVariableType (Integer) Variable type, only when a new variable is created
'-------------------------------------------------------------
' Returns: = 0 - OK
' < 0 - Error number
'-------------------------------------------------------------
' Revision History
'-------------------------------------------------------------
' 12-13-2000 IF:
'=============================================================
' End Code Header block
On Error GoTo HandleErr
Dim db As DAO.Database
Dim rsSettings As DAO.Recordset
Set db = CurrentDb
Set rsSettings = db.OpenRecordset("Settings"
With rsSettings
.index = "PrimaryKey"
.Seek "=", acVariableName, acVariableCategory
If .NoMatch = True Then
If nVariableType = -1 Then
Err.Raise ERROR_PARAM, "AppGlobal.setVariable", "Unspecified variable type"
End If
'New variable record
.AddNew
![Variable] = acVariableName
![Category] = acVariableCategory
![Value] = CStr(vVariable)
![Type] = nVariableType
Else
.Edit
![Value] = CStr(vVariable)
End If
.Update
End With
EXIT_CLOSE:
rsSettings.Close
CLOSE_DB:
db.Close
CLOSE_NOTHING:
Set rsSettings = Nothing
Set db = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "AppGlobal.setVariable"
End Select
setVariable = -1
If db Is Nothing Then
Resume CLOSE_NOTHING
End If
If rsSettings Is Nothing Then
Resume CLOSE_DB
End If
Resume EXIT_CLOSE
End Function
Public Function getVariable(acVariableName As String, Optional acVariableCategory As String = "General"

As Variant
' Parameters:
'-----------
' acVariableName (String) variable name
' acVariableCategory (string) variable category
'-------------------------------------------------------------
' Returns: variable value as variant
'-----------------------------------------------------------
Dim vVarValue As Variant
On Error GoTo HandleErr
vVarValue = DLookup("[Value]", "Settings", "[Variable] = '" & acVariableName & "' AND [Category] = '" & acVariableCategory & "'"

getVariable = vVarValue
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "AppGlobal.getVariable"
End Select
End Function