PC Review


Reply
Thread Tools Rate Thread

Conditional Formating and SetFocus Question

 
 
gngsquared
Guest
Posts: n/a
 
      24th Apr 2010
Thanks in advace. This place has answered a lot of questions before I needed
to ask. Now, I need to ask.

I have a Continous Form [DetailSubForm] based on table [DetailTbl] that has
the following fields. *[DetailID], [DocID], [CompDate],[SubDate],
[ConfirmDate], and [ExpireDate]. The [DocID] field is a dropdown list that
draws the data from the [TrainDocTbl].

I would like to use GetFocus to go to one of the Date fields depending on
the selection made in [DocID]. It would also be nice to be able to declare
the backcolor and forecolor of the whole record depending on that choice.




 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      24th Apr 2010
On Sat, 24 Apr 2010 09:00:01 -0700, gngsquared
<(E-Mail Removed)> wrote:

>Thanks in advace. This place has answered a lot of questions before I needed
>to ask. Now, I need to ask.
>
>I have a Continous Form [DetailSubForm] based on table [DetailTbl] that has
>the following fields. *[DetailID], [DocID], [CompDate],[SubDate],
>[ConfirmDate], and [ExpireDate]. The [DocID] field is a dropdown list that
>draws the data from the [TrainDocTbl].
>
>I would like to use GetFocus to go to one of the Date fields depending on
>the selection made in [DocID]. It would also be nice to be able to declare
>the backcolor and forecolor of the whole record depending on that choice.
>
>
>


You can use code in the AfterUpdate event of DocID:

Private Sub DocID_AfterUpdate
Select Case Me!DocID
Case "this"
Me!CompDate.Setfocus
Case "that"
Me!SubDate.Setfocus
Case "TheOther"
<and so on>
End Select
End Sub

For the color, select any or all of the controls on the subform, and choose
"Format"... "Conditional Formatting" from the menu.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
 
gngsquared
Guest
Posts: n/a
 
      25th Apr 2010
That works great. Thank you.

Can I use the same list to change the BackColor of the field depending on
the selection? If I use Conditional Format to the field I am limited to 3
choices. I would need at least 4 or 5 colors to do it right. And it would be
useful elsewhere.


"John W. Vinson" wrote:

> On Sat, 24 Apr 2010 09:00:01 -0700, gngsquared
> <(E-Mail Removed)> wrote:
>
> >Thanks in advace. This place has answered a lot of questions before I needed
> >to ask. Now, I need to ask.
> >
> >I have a Continous Form [DetailSubForm] based on table [DetailTbl] that has
> >the following fields. *[DetailID], [DocID], [CompDate],[SubDate],
> >[ConfirmDate], and [ExpireDate]. The [DocID] field is a dropdown list that
> >draws the data from the [TrainDocTbl].
> >
> >I would like to use GetFocus to go to one of the Date fields depending on
> >the selection made in [DocID]. It would also be nice to be able to declare
> >the backcolor and forecolor of the whole record depending on that choice.
> >
> >
> >

>
> You can use code in the AfterUpdate event of DocID:
>
> Private Sub DocID_AfterUpdate
> Select Case Me!DocID
> Case "this"
> Me!CompDate.Setfocus
> Case "that"
> Me!SubDate.Setfocus
> Case "TheOther"
> <and so on>
> End Select
> End Sub
>
> For the color, select any or all of the controls on the subform, and choose
> "Format"... "Conditional Formatting" from the menu.
> --
>
> John W. Vinson [MVP]
> .
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      25th Apr 2010
On Sat, 24 Apr 2010 16:30:01 -0700, gngsquared
<(E-Mail Removed)> wrote:

>That works great. Thank you.
>
>Can I use the same list to change the BackColor of the field depending on
>the selection? If I use Conditional Format to the field I am limited to 3
>choices. I would need at least 4 or 5 colors to do it right. And it would be
>useful elsewhere.


Sure. Just set the Backcolor property in the same code; each Case of a Select
Case block can contain as many lines of code as you need:

Private Sub DocID_AfterUpdate
Select Case Me!DocID
Case "this"
Me!CompDate.Setfocus
Me!CompDate.BackColor = vbRed
Case "that"
Me!SubDate.Setfocus
Me!CompDate.BackColor = vbGreen
Case "TheOther"
<and so on>
End Select
End Sub
--

John W. Vinson [MVP]
 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      25th Apr 2010
"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Sat, 24 Apr 2010 16:30:01 -0700, gngsquared
> <(E-Mail Removed)> wrote:
>>
>>Can I use the same list to change the BackColor of the field depending on
>>the selection? If I use Conditional Format to the field I am limited to 3
>>choices. I would need at least 4 or 5 colors to do it right. And it would
>>be
>>useful elsewhere.

>
> Sure. Just set the Backcolor property in the same code; each Case of a
> Select
> Case block can contain as many lines of code as you need:
>
> Private Sub DocID_AfterUpdate
> Select Case Me!DocID
> Case "this"
> Me!CompDate.Setfocus
> Me!CompDate.BackColor = vbRed
> Case "that"
> Me!SubDate.Setfocus
> Me!CompDate.BackColor = vbGreen
> Case "TheOther"
> <and so on>
> End Select
> End Sub



But be aware that on a continuous form, property changes made in code like
this -- as opposed to by conditional formatting -- will apply to every
record, not just the current one.

Conditional formatting's limitation of 3 conditions per object can be hard
to get around. This question came up recently in another thread, and I
posted this (rather cumbersome) workaround, which may possible be useful to
gngsquared:

http://groups.google.com/group/micro...762dfbf998e669


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trim() not trim(); SetFocus() not setFocus() =?Utf-8?B?UGF1bA==?= Microsoft Access VBA Modules 4 8th Oct 2007 11:23 PM
Must SetFocus! May not SetFocus! =?Utf-8?B?QWxsZW5fTg==?= Microsoft Access VBA Modules 5 13th Jun 2007 11:46 PM
Install dates formating using conditional formating? Jerry Eggleston Microsoft Excel Misc 2 9th Nov 2005 06:49 PM
Re: Conditional setfocus peter walker Microsoft Access Forms 0 2nd Dec 2003 12:39 PM
Re: Conditional setfocus Emilia Maxim Microsoft Access Forms 2 3rd Jul 2003 10:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 AM.