Solved

Change BackgroundColor of Header If Form Contains Data

Posted on 2013-12-02
3
286 Views
Last Modified: 2013-12-02
I have a form (frmSub) which is used as a subform on another form (frmMain).  Based on the record show in frmMain, sometimes there is data in frmSub, sometimes there isn't.

The user has requested that the header of the subform has a red background if there is any data displayed.  The subform lists exceptions and they want attention drawn to it if there are any exceptions.
I'm not sure how to accomplish this.  How can I tell if any actual data is displayed or if the contents of the form are blank?
0
Comment
Question by:mlcktmguy
[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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 125 total points
ID: 39689944
try using the subform recordset.. using the event of the control in the main form

with me.frmSub.form.recordset
if  .eof then
     me.frmsub.form.section(1).backcolor=vbred
     else
     
      me.frmsub.form.section(1).backcolor=rgb(255,255,255)
end if

end with
0
 
LVL 61

Accepted Solution

by:
mbizup earned 125 total points
ID: 39689945
Try this in the current event of frmMain:

If Me.frmSub.Form.RecordsetClone.Recordcount > 0 then
    Me.frmSub.Header.BackColor = vbRed
End IF

Open in new window

0
 
LVL 1

Author Closing Comment

by:mlcktmguy
ID: 39690151
I liked the format of the second answer but the syntax gave me an error so I used information form the first answer to get it to work.

Final Code

If Me.frmProperty_Holds_Sub.Form.RecordsetClone.RecordCount > 0 Then
    Me.frmProperty_Holds_Sub.Form.Section(1).BackColor = vbRed
End If
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

630 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