By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Types, Classes: myObject("IWantThisProperty")

P: n/a
Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------

I hope it's clear enough. The fact is that I really would like to keep
getUserValue(String) definition the same since this function is called
at so many place in the program.

Any other suggestion?

Yannick

Oct 18 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The easiest way to do this with a database application is store the details
in a table.

You can use global variables (which in effect is what you are looking at)
but you have the ever present possibility of a code crash wiping them out.

If you use a table to persist these session variables then you can easily
retrieve them and because they are persisted they will not lose their value.
--

Terry Kreft
"Yannick Turgeon" <ve********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------

I hope it's clear enough. The fact is that I really would like to keep
getUserValue(String) definition the same since this function is called
at so many place in the program.

Any other suggestion?

Yannick

Oct 19 '06 #2

P: n/a
MP
"Yannick Turgeon" <ve********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------
I don't know access but if it allows you to create classes similar to vb
then
Class User
Property Name
Property Login
etc
Function getUserValue(thisUser as User, thisValue as string) as variant
Select Case thisValue
Case "Name"
getUserValue = thisuser.Name
Case "Login"
getUserValue = thisuser.Login
etc
End Select
End Function
but i don't understand why you'd want this instead of calling the property
of the class directly
when you need their name you just use User.Name
instead of getUserValue(User, "Name")

when the user logs in(or whatever) create the class and populate the values
then when you need a value just access the class object directly
but I'm probably misunderstanding what you need to do....
:-)
Mark
Oct 19 '06 #3

P: n/a
Thanks to both of you for your ideas and suggestions.

MP a écrit :
but i don't understand why you'd want this instead of calling the property
of the class directly
when you need their name you just use User.Name
instead of getUserValue(User, "Name")
MP, that was an alternative, but the fact is that this function is
already call at hundreds of place in my code and I prefer to change the
inside of the fonction than the hundreds places. But it would be an
obviously better solution to call class properties directly.

For you information, and for posterity (!), I finally chose to use a
Collection to hold the data. Even after more than six years programming
VBA, I have to confess that I never heard about the Collection object.
But it's exactly what I needed to do this.

Thanks again for your time.

Yannick

Oct 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.