Easier way to change colour of text when text box is active?

IshBuild

New member
Local time
Today, 23:33
Joined
Sep 20, 2017
Messages
6
I'm currently working on an add customer form and because it's a lot of data I'd like the label for my text boxes to turn red when i'm using it's corresponding text box.

Currently I'm using VBA to change it as an After_Update from the previous text box entry but I'm hoping there's an easier way?

Thanks
 
Thanks for that link Minty.

I already do something similar but as is often the case Allen Browne does it better.

Particularly useful for me is the ReadFromTag function as I use the tag value a lot to control form actions and can lose track of all the tag values I'm using
 
I started to develop a similar process - then read the AB stuff. As usual pretty simple and well thought out..

I'd like to develop it further using the class method and With Events - then you wouldn't need the clever use of setup form bit, but whether that would ultimately save any coding is probably a bit of a moot point, and I haven't found the time.
 
Last edited:
Minty or Ridders

Have you got any idea how to tweak Allen's code so that aswell as the textbox going yellow on get focus, the label with it turns red in font?

I see he adjusts the label to bold and * if required so im basically wondering how i would tweak it to ignore whether the field is required or not and just amned the label on entry.

The code itself is a bit above my paygrade
 
Minty or Ridders



Have you got any idea how to tweak Allen's code so that aswell as the textbox going yellow on get focus, the label with it turns red in font?



I see he adjusts the label to bold and * if required so im basically wondering how i would tweak it to ignore whether the field is required or not and just amned the label on entry.



The code itself is a bit above my paygrade



Yes. I've done that using my version of the code. Will post later today unless you get another answer first


Sent from my iPhone using Tapatalk
 
Well that proved slightly more tricky than I expected.
Anyway attached are accdb & mdb versions of what you wanted
I've made the colours slightly more obvious but you can change them if you want.

attachment.php
 

Attachments

Hi Ridders, Just checked the code. THanks so much for working on it.
It through up an error which i will post later. Just wanted to post gratitude for effort.

As soon as out of meeting will post issue it is throwing up.
 
Hi Ridders, Just checked the code. THanks so much for working on it.
It through up an error which i will post later. Just wanted to post gratitude for effort.

As soon as out of meeting will post issue it is throwing up.

When you reply, let me know which Access version & whether you used ACCDB or MDB file
 
Hi

Currently using access 2016 and i believe accdb.

When i try it in the file you uploaded it works fine.

I copy and paste your module over and save my db. I created new form with 4 new textboxes and when i tab form first 1 to next one it throws an error on the line attached in image.
 

Attachments

  • Capture2222.JPG
    Capture2222.JPG
    78.7 KB · Views: 169
Do you have a form called frmClient, as that is what Colin's example is using.?
You need to change the name of the form to that of yours, unless it can be modified to use the current form name somehow.
 
Hi Gasman

In the code Colin was adapting i dont think it was sensitive to the frm name. Could be wrong but i thought that is how it worked.
 
I see what you mean in the code regarding form name. Amended mine to match that name but still falters at same point.
 
Ok - apologies for quick fire messages. Now have it working as i hadnt appreciated that the Lbl had to be anmes LblXXXX With the XXXX matching the name of the textbox.

SO Colin i guess the final question is, is there a way to make it so it uses the current frm rather than having to type in frmclient as i want to use this code on all my forms?
 
here is a sample.
if you want to adapt to your
code, just copy the two
Classes there.

also take note on how
the classes are used
on the Load Event of
Customers Form.

Hi. Cant seem to see the smaple you are mentioning in your post?
 
No my apologies, I had not spotted that the form name was in a module, not actually in the form.
There has to be a way of linking the data control to the label, and that is as good as any.

Arne's is also a good method, but I get confused with classes at present. :D
 
Ok - apologies for quick fire messages. Now have it working as i hadnt appreciated that the Lbl had to be anmes LblXXXX With the XXXX matching the name of the textbox.

SO Colin i guess the final question is, is there a way to make it so it uses the current frm rather than having to type in frmclient as i want to use this code on all my forms?

Hi

In the original, there were 4 places which specified the form name

Attached is a modified 'generic' version which uses the currently active form name.
So the code will now work with different forms in the same database

Sorry forgot to mention that the label MUST always match the name of the control for this part to work
e.g. control name = LastName, label name= lblLastName
 

Attachments

Minty or Ridders

Have you got any idea how to tweak Allen's code so that aswell as the textbox going yellow on get focus, the label with it turns red in font?

I see he adjusts the label to bold and * if required so im basically wondering how i would tweak it to ignore whether the field is required or not and just amned the label on entry.

The code itself is a bit above my paygrade

This intrigued me, so this is my attempt.
 

Attachments

Hi Paul

Yup - that works as well!
Funnily enough that was roughly what I did on the first attempt but went for a different solution in the end.

As with most things in Access there are endless ways of doing the same thing....

Speaking of which I was just going to look at arnelgp's version but its gone.
Have you deleted it arnel or do I need new glasses?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom