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

x
?
Solved

access forms conditional formatting

Posted on 2013-01-27
5
Medium Priority
?
317 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 49

Expert Comment

by:Dale Fye
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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

783 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