Solved

Change BackgroundColor of Header If Form Contains Data

Posted on 2013-12-02
3
279 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

Independent Software Vendors: 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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

738 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