Solved

access forms conditional formatting

Posted on 2013-01-27
5
306 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

This collection of functions covers all the normal rounding methods of just about any numeric value.
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

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

18 Experts available now in Live!

Get 1:1 Help Now