same error message for multiple textboxes

BarryMK

4 strings are enough
Local time
Today, 03:23
Joined
Oct 15, 2002
Messages
1,350
I am currently placing the following simple error message in the on click event of several text boxes on a form. (Users cannot edit any field with a blue background).

Private Sub txt4_Click()
MsgBox "You do not have permission to edit blue fields ", vbInformation, "User error"
End Sub

I was wondering if there is a neater/better way to do this, such as placing one piece of code on the form which covers all the text boxes which have a blue background or some other unique attribute?
 
I've had a quick look around, and it seems it should be possible using something along the lines of :
Code:
If Me.txtbox.backgroundCol = "numerical value of a blue"   Then
etc.

But I'm not sure of the syntax. I think all an objects properties are available somewhere, and the background colour is one of them.

Hope this at least gives you somewhere to look into, until someone better gives you more specific help.

Happy coding
 
If somebody doesn't have permission to edit them then why are they enabled in the first place?

On the form's open/load event you can check if the user has permission and enabled/disable colour/discolour the controls accordingly.
 
Re: Re: same error message for multiple textboxes

Thanks Smee appreciate the suggestion.

Mile-O-Phile said:
If somebody doesn't have permission to edit them then why are they enabled in the first place?

Hi Mile
They are disabled! My main problem is that the users may only get to use this dbase once every few months and unfortunately they are generally not the brightest of stars into the bargain.

The dbase is laid out in the simplest step by step format, moving logically from one popup to another, literally all they need to do is follow two or three simple steps, in order, on each form. A splash screen on opening reminds them they can't edit blue fields but they still try.

I'm just trying to user proof for a special bunch of users. It may seem like overkill but I'm trying to get a message across to the unthinking. In this instance the message boxes work fine, I was just trying to minimise the amount of code behind each form for the sake of efficiency
 
Suggestion

Are the useres set up on a level system, so if admin is case 1, user is case 2, then you could just hide them in the first place or show them if they have access, this would be the best because then there is no confusion why they cant click it cause it is available, but if its hidden for them. They wouldnt even know its there :D
________
S360
 
Last edited:
Hi a.sinatra, sorry I've been occupied elsewhere. To explain, all the fields carry information that the user needs to see but not edit - but the lovely users still try to edit them anyway and then ring admin to ask why they can't input stuff. (Don't even go down the training issue route!) As I'm not allowed to pass a million volts through their keyboards I'm happy to put in an error message on the OnClick events in the hope that after getting that message 10 times they'll get the message. I was simply wondering if I could code one error message for a bunch of fields on a form rather than place it on all the fields. Either way it ain't life or death. Cheers.
 

Users who are viewing this thread

Back
Top Bottom