A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional Format



 
 
Thread Tools Display Modes
  #1  
Old April 14th, 2008, 04:55 AM posted to microsoft.public.access.forms
quinto via AccessMonster.com
external usenet poster
 
Posts: 105
Default Conditional Format

Would like a field in a form to turn yellow when another field in the same
record has focus but I have problems with the expression, is it possible?

Thanks

Quinto

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200804/1

  #2  
Old April 14th, 2008, 08:29 AM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 130
Default Conditional Format

On Apr 14, 5:55*am, "quinto via AccessMonster.com" u35571@uwe wrote:
Would like a field in a form to turn yellow when another field in the same
record has focus but I have problems with the expression, is it possible?

Thanks

Quinto

--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200804/1


Hm, not sure that is possible? However, you can always use some code:

Private Sub SecondField_GotFocus()
FirstField.BackColor = vbYellow
End Sub

Private Sub SecondField_LostFocus()
FirstField.BackColor = vbWhite
End Sub

Regards,
Branislav Mihaljev, Microsoft Access MVP
  #4  
Old April 15th, 2008, 07:48 AM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 130
Default Conditional Format

On Apr 14, 2:01*pm, "quinto via AccessMonster.com" u35571@uwe wrote:
It work but, not as intended. the whole column turns yellow, can I add
another line of code to apply to the same record only?

Thanks

Quinto



wrote:
Would like a field in a form to turn yellow when another field in the same
record has focus but I have problems with the expression, is it possible?

[quoted text clipped - 5 lines]
--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200804/1


Hm, not sure that is possible? However, you can always use some code:


Private Sub SecondField_GotFocus()
* *FirstField.BackColor = vbYellow
End Sub


Private Sub SecondField_LostFocus()
* *FirstField.BackColor = vbWhite
End Sub


Regards,
Branislav Mihaljev, Microsoft Access MVP


--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200804/1


It looks like (you didn't tells us so) that you have subform or form
as Continuous form or as Datasheet view where one field in Design View
contains many records in Form View. Using above code it will paint
whole column (it actually paints one field on form).

Regards,
Branislav Mihaljev, Microsoft Access MVP
  #6  
Old April 21st, 2008, 04:31 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Conditional Format

That's a different question entirely, and depends on exactly what you mean by
"highlight the
whole record."

You can change the backcolor of each textbox in the record using Conditional
Formatting by

Holding down the Shift Key and selecting all of the textboxes
Going to Format - Conditional Formatting and entering

Expression Is [YourFieldName] = "Adams"

or

Expression Is [YourFieldName] 100

or whatever, then choose your backcolor. The square brackets have to be
around the field name.

Another method, that's quite a bit more complicated, involves using an
unbound textbox below your other textboxes.

Make it slightly taller than your other textboxes, and long enough to appear
a little to the left of and a little to the right of your row of textboxes.

With the unbound textbox selected, goto Format and select "Send to Back"

Set the Conditional Format for this unbound textbox as described above.

Now, position the textbox so that it's behind the row of other textboxes,
slightly above and below, and slightly to the left and to the right of the
row.

Now, when the conditional for the given control is met, the unbound textbox,
which should now "envelop" your row of textboxes, will change color, "hi-
lighting" the record.

The only problem with this method is that if the unbound control gets focus,
it will come to the front, covering your row of textboxes. To prevent this

For the unbound textbox, go to Properties - Other and set Tab Stop to No

Then place this bit of code

Private Sub YourUnboundTextbox_Click()
Me.Field1.SetFocus
End Sub

where Field1 is any control on your record you'd like the focus on. By doing
this, if the user should acidentally click on the "background" textbox, focus
will go to the Field1 and the textboxes won't be covered up.

Good luck!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200804/1

  #7  
Old April 23rd, 2008, 04:30 AM posted to microsoft.public.access.forms
quinto via AccessMonster.com
external usenet poster
 
Posts: 105
Default Conditional Format

Thank you for your attempt to help me out. I do not want to the record to
change color when a condition is met but I want the record to change color
when the "ID" field has focus. This will make it easier for the user to focus
on the whole raw across the form.
Thanks Again

Quinto

Linq Adams wrote:
That's a different question entirely, and depends on exactly what you mean by
"highlight the
whole record."

You can change the backcolor of each textbox in the record using Conditional
Formatting by

Holding down the Shift Key and selecting all of the textboxes
Going to Format - Conditional Formatting and entering

Expression Is [YourFieldName] = "Adams"

or

Expression Is [YourFieldName] 100

or whatever, then choose your backcolor. The square brackets have to be
around the field name.

Another method, that's quite a bit more complicated, involves using an
unbound textbox below your other textboxes.

Make it slightly taller than your other textboxes, and long enough to appear
a little to the left of and a little to the right of your row of textboxes.

With the unbound textbox selected, goto Format and select "Send to Back"

Set the Conditional Format for this unbound textbox as described above.

Now, position the textbox so that it's behind the row of other textboxes,
slightly above and below, and slightly to the left and to the right of the
row.

Now, when the conditional for the given control is met, the unbound textbox,
which should now "envelop" your row of textboxes, will change color, "hi-
lighting" the record.

The only problem with this method is that if the unbound control gets focus,
it will come to the front, covering your row of textboxes. To prevent this

For the unbound textbox, go to Properties - Other and set Tab Stop to No

Then place this bit of code

Private Sub YourUnboundTextbox_Click()
Me.Field1.SetFocus
End Sub

where Field1 is any control on your record you'd like the focus on. By doing
this, if the user should acidentally click on the "background" textbox, focus
will go to the Field1 and the textboxes won't be covered up.

Good luck!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200804/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.