Solved

Change BackgroundColor of Header If Form Contains Data

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

758 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

22 Experts available now in Live!

Get 1:1 Help Now