ADP Client (Local) Storage

  • Thread starter Thread starter Anthony Headley
  • Start date Start date
A

Anthony Headley

Hey all, quick question,

I would like to store some local information "In" the clients ADP but I'm
not too sure of the best way to do this.

For the time being I would like to save two simple variables:

1) The last logged on user. At the moment I create a file with VBA with
the users name after a successful login.

2) The current Client ADP Version, at the moment I store this in a module
function al la
~Snip~
Function get_client_version()
get_client_version = "1.4"
End Function
~Snip~

Is there a way that I can do this in a dataset local to the ADP, without
creating an external file or registry entry that the user might be able to
fiddle with?


Thanks again.

H
 
Maybe you could use the custom properties collection, something like:

Public Sub SetProperty( _
ByVal strPropName As String, _
ByVal varPropType_Bidon As Integer, _
ByVal varPropValue As Variant)


Const cProcedureName As String = "SetProperty"
On Error GoTo Err_Handler


Dim db As CurrentProject
Set db = Application.CurrentProject


' Properties are string values.
If (IsNull(varPropValue)) Then varPropValue = ""


Dim i
For i = 0 To db.Properties.Count - 1
If (db.Properties(i).name = strPropName) Then
db.Properties(strPropName).Value = varPropValue
GoTo Exit_Sub
End If
Next


db.Properties.Add strPropName, varPropValue


Exit_Sub:
On Error GoTo 0
Set db = Nothing
Exit Sub


Err_Handler:


''''' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
Resume Exit_Sub


End Sub


' GetProperty(): returns TRUE if the property was already known; FALSE
otherwise.
' The value itself is passed by argument.


Public Function GetProperty( _
ByVal strPropName As String, _
ByRef strPropValue As Variant) As Boolean


Const cProcedureName As String = "GetProperty"
On Error GoTo Err_Handler


Dim db As CurrentProject
Set db = Application.CurrentProject


Dim i
For i = 0 To db.Properties.Count - 1
If (db.Properties(i).name = strPropName) Then
strPropValue = db.Properties(strPropName)
GetProperty = True
GoTo Exit_Function
End If
Next


GetProperty = False


Exit_Function:
On Error GoTo 0
Set db = Nothing
Exit Function


Err_Handler:
GetProperty = False
''''' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
Resume Exit_Function


End Function


Also, notice that unlike with MDB, the user cannot access this collection
from the menu.


--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)



Hey all, quick question,

I would like to store some local information "In" the clients ADP but I'm
not too sure of the best way to do this.

For the time being I would like to save two simple variables:

1) The last logged on user. At the moment I create a file with VBA with
the users name after a successful login.

2) The current Client ADP Version, at the moment I store this in a module
function al la
~Snip~
Function get_client_version()
get_client_version = "1.4"
End Function
~Snip~

Is there a way that I can do this in a dataset local to the ADP, without
creating an external file or registry entry that the user might be able to
fiddle with?


Thanks again.

H
 
Perfect. That is exactly what I was looking for. I didn't realize that the
properties collection was persistent, though that makes perfect sense.
This is a perfect solution.

While I was in my halfway point between MDB and ADP I would store local
data in native MBD tables and the real data via linked tables, so I have
never looked at the Porperty collection, but now... I code....

Thanks!
 
Back
Top