Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

access forms conditional formatting

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
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…

722 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