Solved

After update to change form background

Posted on 2014-01-16
3
350 Views
Last Modified: 2014-01-16
After I update a field in a form, I would like it to change the color of the form. I already put code in that on the form for an "On Current" event. This code is working great. If possible I would like it to change if the field changes, not just when you click onto the form.

The code of the "On Current" of the form is this:

Private Sub Form_Current()

Select Case Me!cmOffice
     Case "Orange County"
      Me.Detail.BackColor = vbGreen
    Case "Riverside"
     Me.Detail.BackColor = vbBlue
     Case Else
      Me.Detail.BackColor = vbWhite
End Select

End Sub

WHat would the code be for the "After Update"?
0
Comment
Question by:cansevin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39787243
If I understood you correctly, it would be the same thing.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39787247
use the same codes that you use in the Current event in the AfterUpdate event of control cmOffice
0
 
LVL 58
ID: 39787269
While it would be the same code in the AfterUpdate event of the control, you want to structure this a bit differently.

What you want is the code in a single place that you call from both locations.

So open up your form module, and at the top enter:

Sub SetFormBackGround()

End Sub will pop in.

Now take the code:

Select Case Me!cmOffice
     Case "Orange County"
      Me.Detail.BackColor = vbGreen
    Case "Riverside"
     Me.Detail.BackColor = vbBlue
     Case Else
      Me.Detail.BackColor = vbWhite
End Select


and paste it in between the two lines.

 Now go back to the OnCurrent and AfterUpdate of any controls involved and type:

  SetFormBackGround

 and remove the code that's already there.

 Now your code for setting the form background is in only one place, which makes it easier to maintain.

Jim.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question