User preferences (1 Viewer)

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
Form User preferences

[This same question has been posted on MSDN as well. Link will be provided soon.]
Hi folks!

Recently, I have come across an interesting article about Access Forms that was talking (and providing a valid working example) of user preferences. The idea was basically that there was a form which once you open it, allows you to change the background and some other colors.

The end result: Other forms that you open will have the same background / other colors. The thing is, the particular article was referring to user preferences set for the forms overall. In other words, if you log into your database "app", the settings that may have been set by someone else would still be applied (by settings, I refer to the colors).

Now my question is: Would this be possible to be set up for each user to have their own preferences so that when you log in, the settings chosen by you only would be applied? I have my doubts, but this would definitely give a more dynamic feeling when using an Access database.

The article that was mentioned above hasn't been linked since it's an outer link / link to an external website instead of this one.
 

Attachments

  • user_preferences_sample.jpg
    user_preferences_sample.jpg
    36.6 KB · Views: 110
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:07
Joined
Feb 19, 2002
Messages
43,486
Since you need to be able to distribute new copies of the FE without destroying people's personal settings, the table that holds the settings needs to be in the BE where it is shared and that means that each setting needs to be tagged with the userID in addition to what the setting controls.

I've never attempted it for the simple reason that i work as a consultant and that means my time on the job is limited and frankly, most clients don't want to pay me to do stuff like this.
 

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
Since you need to be able to distribute new copies of the FE without destroying people's personal settings, the table that holds the settings needs to be in the BE where it is shared and that means that each setting needs to be tagged with the userID in addition to what the setting controls.

I've never attempted it for the simple reason that i work as a consultant and that means my time on the job is limited and frankly, most clients don't want to pay me to do stuff like this.

That does sound like the thing that would have to be done, unfortunately. Would still love to implement it, so I'll keep searching. Thanks for the reply.
 

isladogs

MVP / VIP
Local time
Today, 19:07
Joined
Jan 14, 2017
Messages
18,258
You could consider providing a number of themes as user options.
e.g. 1 = Blue ; 2 = Red ; 3 = Green etc
Then users could select one of the themes & have that value stored in the Users table in the BE

A procedure could be written to update each form as it is opened

Downside of this is that you would need to ensure all forms were designed based on a consistent default theme

I'm sure it would be popular here as a sample database if done well.
 

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
You could consider providing a number of themes as user options.
e.g. 1 = Blue ; 2 = Red ; 3 = Green etc
Then users could select one of the themes & have that value stored in the Users table in the BE

A procedure could be written to update each form as it is opened

Downside of this is that you would need to ensure all forms were designed based on a consistent default theme

I'm sure it would be popular here as a sample database if done well.

That certainly sounds good. While I doubt I would be able to write such pieces of VBA code as I am not really an expert when it comes to it, but I'm sure I'd be able to implement it if I had a starting point. Thanks for the reply.
 

isladogs

MVP / VIP
Local time
Today, 19:07
Joined
Jan 14, 2017
Messages
18,258
Here's the link to the article by Danny Lessandrini that you mentioned in post #1.
https://www.databasejournal.com/features/msaccess/article.php/3605656/Implement-User-Preferences-in-MS-Access.htm

I thought it looked familiar when I saw the image

His post from 2006 predates the use of themes in Access but the idea is the same

Danny is suggesting saving the user preferences to the registry rather than the BE. This has the disadvantage that user preferences won't be available if they work on a different PC.

Attached is Danny's example database from that article.

The code is very easy to implement and could be further extended to :
a) include other items such as user selection of font name / colour / size.
b) using a function called when each form is loaded instead of repeating the same code in each form

Its also easy to get some truly hideous results :
 

Attachments

  • ImplementUserPreferences.zip
    83.8 KB · Views: 75
  • HideosColours.PNG
    HideosColours.PNG
    17.3 KB · Views: 269
Last edited:

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
Here's the link to the article by Danny Lessandrini that you mentioned in post #1. Link Removed
I thought it looked familiar when I saw the image

His post from 2006 predates the use of themes in Access but the idea is the same

Danny is suggesting saving the user preferences to the registry rather than the BE. This has the disadvantage that user preferences won't be available if they work on a different PC.

Indeed. Plus, the preferences would be reset when you restart your PC with Danny's approach if I am not mistaken.

My main concern is that I am not 100% sure how to approach the problem. I'd think of having a function written in VBA that takes a string parameter (e.g "Blue", "Green", etc.) and has a switch statement inside of it which modifies the form parameters depending on the string parameter value. Though, I am not quite sure what values do the colors have (RGB? Hex? something else?) as well as what type of data they are (VARCHAR, INT, etc.) nor what the names of those form parameters are (this one could easily be solved).

Now that I think of it a bit more, this sounds like a valid plan. I'll do some more research and will try to make a decent sample. Thanks.
 

isladogs

MVP / VIP
Local time
Today, 19:07
Joined
Jan 14, 2017
Messages
18,258
Indeed. Plus, the preferences would be reset when you restart your PC with Danny's approach if I am not mistaken.

Wrong. They are saved to the registry HKCU hive

My main concern is that I am not 100% sure how to approach the problem. I'd think of having a function written in VBA that takes a string parameter (e.g "Blue", "Green", etc.) and has a switch statement inside of it which modifies the form parameters depending on the string parameter value. Though, I am not quite sure what values do the colors have (RGB? Hex? something else?) as well as what type of data they are (VARCHAR, INT, etc.) nor what the names of those form parameters are (this one could easily be solved).

Just follow Danny's approach:
Set the colours on a user preference form
Save to registry (or the BE file)
Get user settings when form is opened

Use Access OLE colours or if preferred VBA defaults like vbRed, vbCyan etc
Attached is a simple colour converter you may find useful

Now that I think of it a bit more, this sounds like a valid plan. I'll do some more research and will try to make a decent sample. Thanks.

Danny's example basically provides all you need to get started
 

Attachments

  • ColourConverter.accdb
    504 KB · Views: 82

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:07
Joined
Feb 19, 2002
Messages
43,486
Current versions of Access use themes. You could let them change the database theme and that changes ALL forms and reports. I don't think you really want to manage this on a form by form, report by report basis.

The one thing to worry about with forms is that they are not interchangeable and there is noting in their names that helps you to identify which can be used in place of another. The problem is not the color schemes. It is the fonts. Depending on how condensed your forms and reports are, you might find that switching from themeA to themeB could cause all your labels to be clipped.
 

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
Hi arman / Mark

Just discovered you have cross posted this at MSDN.

Please follow forum guidelines if you cross post:
State you have done so and provide a link to the other thread
Otherwise there is a risk of people repeating existing answers

Indeed. I had a feeling I'd find a solution faster if I had posted it on both sites. I am going to include the link once my limit of 10 posts has been taken out.

Wrong. They are saved to the registry HKCU hive



Just follow Danny's approach:
Set the colours on a user preference form
Save to registry (or the BE file)
Get user settings when form is opened

Use Access OLE colours or if preferred VBA defaults like vbRed, vbCyan etc
Attached is a simple colour converter you may find useful



Danny's example basically provides all you need to get started

Would I be able to store the color value in a table so that I can load it when a specific user logs in so that the forms' colors from that table would be applied? I mean, would I store it as "Short Text" or as a "Number" in the table?
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 19:07
Joined
Jan 14, 2017
Messages
18,258
Indeed. I had a feeling I'd find a solution faster if I had posted it on both sites. I am going to include the link once my limit of 10 posts has been taken out.

Good point - might be worth site admins reviewing that policy at some stage

Would I be able to store the color value in a table so that I can load it when a specific user logs in so that the forms' colors from that table would be applied? I mean, would I store it as "Short Text" or as a "Number" in the table?

If using settings like vbRed, vbCyan then datatype needs to be text.
Otherwise, store colour values as long integer numbers

BTW - in case you haven't seen it, I sent you a visitor message yesterday
 

Arman

Registered User.
Local time
Today, 20:07
Joined
Dec 21, 2017
Messages
19
Good point - might be worth site admins reviewing that policy at some stage



If using settings like vbRed, vbCyan then datatype needs to be text.
Otherwise, store colour values as long integer numbers

BTW - in case you haven't seen it, I sent you a visitor message yesterday

After giving it a shot, Access actually allowed me to store and read the color values in both Short Text and Number. I will stick to Long Int, though. It feels safer as the source of the value may be a picker.

As for the Visitor message, I hadn't noticed it until you mentioned it. I will watch out for it. Thanks.
 

isladogs

MVP / VIP
Local time
Today, 19:07
Joined
Jan 14, 2017
Messages
18,258
Let us know how you get on with this & if you need more help.

I did a brief tourist visit to Bosnia last year - Mostar inevitably ... hope to go back and see more of the country in the future
 

Users who are viewing this thread

Top Bottom