Solved

access forms conditional formatting

Posted on 2013-01-27
5
313 Views
Last Modified: 2013-02-05
I have a subform Invoices and a linked subform Vouchers.
They are linked via a textbox and master and child.

One invoice may have several vouchers.

How can I format the invoices form so that if there is a related voucher (in a subform) the invoice form background (say) is a different colour to where there is no related voucher
0
Comment
Question by:topUKlawyer
[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
5 Comments
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 38824097
I'm confused, if these are both subforms on the same form, then if there is a voucher for a particular invoice, it will show up in the subform.

Why do you need some other visual indication?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38824104
So these are 'sibling' subforms?

I would use VBA in the Current Event of the Invoices Subform:

Private Sub Form_Current()
Dim rs as DAO.Recordset

Set rs = Me.Parent.Vouchers.Form.RecordsetClone
rs.FindFirst "ID = " & Me.ID    '<-- replace ID with whatever field they have in common
'rs.FindFirst "ID = '" & Me.ID  "'"  '<-- Use this if that field is TEXT

If rs.Nomatch = true then Exit Sub

Me.Detail.BackColor = vbBlue

Set rs = nothing

End Sub

Open in new window

0
 

Author Comment

by:topUKlawyer
ID: 38824132
they are both subforms on a master form called clients.

They are linked via a freestanding textbox which has no use but to link subforms.

(InvoicesID as the primary index in Invoices to the foreign InvoicesID field in Vouchers)

If this is sibling subforms then  yes
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38824183
Ok..
Try my code substituting InvoiceID where I have used ID.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38857064
My guess is that what mbizup posted should work.

What I have also done in the past is to simply use Dcount to see if any child records exist, then key off the dcount to trigger conditional formatting

For example this will see if a customer has any orders:

If Dcount("OrderID", "tblOrders", "CustID=" & me.CustID)=0 then
    'Do something
...


Again, this is just a FWIW...

JeffCoachman
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

752 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