Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change BackgroundColor of Header If Form Contains Data

Posted on 2013-12-02
3
Medium Priority
?
296 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 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 500 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
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 …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

885 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