Solved

access forms conditional formatting

Posted on 2013-01-27
5
310 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
5 Comments
 
LVL 47

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
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…

776 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