Solved

Change BackgroundColor of Header If Form Contains Data

Posted on 2013-12-02
3
271 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
3 Comments
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now