Highlighting a field in a form/ Putting Markers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I would like to know how can I highlight a field with a bright coulour
automatically if it is left blank , so that the next time the database is
opened, we know that the field has to be filled. Also even if I can put a
button to flash Red if the Form is incomplete, and Green if it is complete
would do.
PLEASE HELPPPPPPP!!!!!!!!!!!
Thanks.
 
One option is to set conditional formatting on each field. Evaluate if it
is blank and then set the format accordingly.
There are other ways as well.


Rick B
 
Don't know about the flashing, but you can change the background & foreground
colors of the textbox with code in the Form_Open event of the form like:

Me.Textbox1.BackColor = vbRed

Other examples:
Me.Textbox2.ForeColor = vbGreen
Me.CommandButton1.ForeColor = vblue <- To change the font color of the button

- Marvin
 
Hi,
I tried the statements you sent me below and seem to be getting a lot of
errors, I wanted to know what " Me" stands for ?
Thanks for your help
 
Hi FC,

'Me' acts as a reference to the object in which the code resides (similar to
'this' in Java). In this case it references the form in which your code is
written.

One error may be generated because I left off the '1' in the first
"Me.Textbox..."

If you had a form with a text box on it, titled, 'Textbox1', and made the
Open event for the form look like the following, the background color of the
textbox should be red.

Private Sub Form_Open(Cancel As Integer)
If IsNull(Me.Textbox1) Then
Me.Textbox1.BackColor = vbRed
End If
End Sub

~Marvin
 
Hi Marvin,

Still having problems, Sorry for the trouble.

If my form Name is "SleepLabQC"
Label of my Text Field is "SIGNATURE"
The control Source for the above Text Field is"SIGNATURE"

THEN COULD YOU TELL ME HOW THE STATEMENTS FOR THE MACRO WILL BE? I AM QUIET
NEW AT THIS AS YOU CAN TELL.
THANKS
 
Hi Marvin,

Still having problems, Sorry for the trouble.

If my form Name is "SleepLabQC"
Label of my Text Field is "SIGNATURE"
The control Source for the above Text Field is"SIGNATURE"

THEN COULD YOU TELL ME HOW THE STATEMENTS FOR THE MACRO WILL BE? ALSO WILL THE "VBRED" FILL THE TEXTBOX WITH RED COLOR? I AM QUIET
NEW AT THIS AS YOU CAN TELL.
THANKS
 
FC,

It’s no trouble. Some of the confusion is probably in terminology. In my
example, textbox1 is the “Name’ of the text box ‘Control’ on the form. If you
bring up the Properties window for the text box, the first listing on the
‘Other’ tab is the’Name’ of the text box. If you name the text box SIGNATURE,
the code would be:

Private Sub Form_Open(Cancel As Integer)
If IsNull(Me.SIGNATURE) Then
Me.SIGNATURE.BackColor = vbRed
End If
End Sub

(To bring up the Properties window, right click on the text box and select
‘Properties’)

~Marvin
 
Hi Marvin,
Thanks for the reply, I just have one more question, IS "Me" the fome name?
Thanks.
 
FC,

Me is the form object (or, perhaps more accurately, the reference to an
instance of the form). 'Me.Name' references the name of the form. For example:

msgbox Me.Name

would display the name of the form (if executed in a subroutine in the form
code).

~Marvin
 
Back
Top