Solved

After update to change form background

Posted on 2014-01-16
3
349 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 57
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 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