Need text boxes greyed when not filled with data

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

Guest

I have a form that is documented with all kinds of data.
There are a few fields that will not be completed because others are.
The user wishes that the blank data fields be greyed when no data is entered.
How can I do this?
Thank you
 
To change the color of a text box, use

Me.[FieldName].BackColor = 12632256 ' change to grey
Me.[FieldName].BackColor = 16777215 ' change back to white

It's depend when you want to assign the colors, if it's after you update a
certain field, then on the after update event of this field you can write
If IsNull(Me.FieldName) then
Me.[FieldName].BackColor = 16777215 ' change back to white
Else
Me.[FieldName].BackColor = 12632256 ' change to grey
End if
 
Set the Enabled property of the textbox to False to gray it out, or to True
to allow the users to use it again.
 
Hello. Thanks for your response.
I have a few more questions.

1st, where do I find the # you refrerenced for the colors? I decided
instead of grey, I would like the text box to turn light green when it
doesn't have any data typed into it.
2nd, The code you gave me greyed in the box when I typed in data Vs turning
grey when there was not data typed.
3rd, Will the code work if I have already completed a record, or do I need
to re-do the record.
Thanks so much for your help. Have a great weekend.

Ofer said:
To change the color of a text box, use

Me.[FieldName].BackColor = 12632256 ' change to grey
Me.[FieldName].BackColor = 16777215 ' change back to white

It's depend when you want to assign the colors, if it's after you update a
certain field, then on the after update event of this field you can write
If IsNull(Me.FieldName) then
Me.[FieldName].BackColor = 16777215 ' change back to white
Else
Me.[FieldName].BackColor = 12632256 ' change to grey
End if

--
I hope that helped
Good Luck


Mary A Perez said:
I have a form that is documented with all kinds of data.
There are a few fields that will not be completed because others are.
The user wishes that the blank data fields be greyed when no data is entered.
How can I do this?
Thank you
 
To get the number of each color, you can select an object in the form (text
box), change the backcolor and you'll get the number, you can copy it.
To make life easier make const of each color, that way you wont need to
remember the numbers
Create in a module
Global Const White = 16777215
Global Const Gray = 12632256

And then all you need to do is write the name of the const
Me.TextBoxName = Gray
==========================================
About the code, try this
If IsNull(Me.FieldName) Or Me.FieldName = "" then
Me.[FieldName].BackColor = 16777215 ' change back to white
Else
Me.[FieldName].BackColor = 12632256 ' change to grey
End if
============================================
If you want the fields to change the colors when you move between records,
add this code also to the OnCurrent event of the form

=========================================
Mary A Perez said:
Hello. Thanks for your response.
I have a few more questions.

1st, where do I find the # you refrerenced for the colors? I decided
instead of grey, I would like the text box to turn light green when it
doesn't have any data typed into it.
2nd, The code you gave me greyed in the box when I typed in data Vs turning
grey when there was not data typed.
3rd, Will the code work if I have already completed a record, or do I need
to re-do the record.
Thanks so much for your help. Have a great weekend.

Ofer said:
To change the color of a text box, use

Me.[FieldName].BackColor = 12632256 ' change to grey
Me.[FieldName].BackColor = 16777215 ' change back to white

It's depend when you want to assign the colors, if it's after you update a
certain field, then on the after update event of this field you can write
If IsNull(Me.FieldName) then
Me.[FieldName].BackColor = 16777215 ' change back to white
Else
Me.[FieldName].BackColor = 12632256 ' change to grey
End if

--
I hope that helped
Good Luck


Mary A Perez said:
I have a form that is documented with all kinds of data.
There are a few fields that will not be completed because others are.
The user wishes that the blank data fields be greyed when no data is entered.
How can I do this?
Thank you
 
Back
Top