Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Profiles"

Profiles

Is there any way of obtaining a list of the profiles in a database or triggering an error handling routine in the macro?

Current user: [none]
Register / Log In · Help

Posted By Post

Keith1

1-Nov-2014 17:26

I use the "run macro at start up" facility to automate the opening of the database and to configure certain options when a user fires up the client. I now want to switch to a particular profile based on the user's id (i.e. the profile name and user name are the same) - so that I can tailor what they are allowed to do and also record who last updated a record. I know the user could do this manually but would prefer to automate if at all possible. However, if there is no specific profile set up for a user, I want them to just use the "Default" profile.

The attributes/methods currently available allow me to determine the active profile (Database.Profile) or to set a different one (Database.SetProfile(xxx)) but not to discover what profiles have been defined. If the profile doesn't exist, SetProfile() causes Cardbox to raise an error message and the macro stops executing at that point. I tried setting an error handler (as much as this is possible in VBS) but this is not triggered because the macro is terminated first!

I do not want to hard code a lookup table in the macro. I suppose I could create a separate database that lists users who have a specific profile but that is just duplicating the list of profiles.

So, is there a way of either:
a) Discovering what profiles have been defined?
or
b) Getting Cardbox to recognise and transfer control to an error handling routine in the macro?

If anyone has an answer/suggestion, thanks in advance!

bert

1-Nov-2014 21:55

Hi,
Perhaps is it an option to permit anyone entering the database to get the default profile.
Then, when entered the database, switch to a profile of the currentuser.

If you want to switch to a non existing profile, Cardbox raises an error.
However, on error resume next will suppress this error. I just tested this:

on error resume next
Database.SetProfile "non existing name","password"
msgbox Err.Number
The msgbox is always displayed: error number -1606217207

I hope this will help you.
Regards
Bert

Keith1

2-Nov-2014 09:20

Thanks Bert, that works for me too.
Your example has pinpointed where I went wrong in my macro.
I must improve my reading ability...
:-)

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home