473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Demo of Conditional format in subform - Unlimited colours

mshmyob
904 Recognized Expert Contributor
This demo is a simple way to change the colours in a subform to highlite different conditions.

Access only allows a maximum of 4 conditional changes to individual controls but with this simple trick you can apply thousands of colour changes to any number of controls or even entire rows in a subform set to continuous forms.

Note: This works only in AC2007 I believe. Since I notice more and more AC2007 questions and always see questions about conditional formatting I decided to throw this together for the community.

If you have any questions please feel free to ask.

cheers
Attached Files
File Type: zip conditionalsubform.zip (32.7 KB, 1291 views)
Apr 24 '09 #1
5 9599
NeoPa
32,557 Recognized Expert Moderator MVP
I've moved this across to the Insights area (as well as noted so I can direct people here when required).
Apr 24 '09 #2
FishVal
2,653 Recognized Expert Specialist
I don't have Access 2007, but still curious to know what method was applied to achieve the goal. Could you please describe the basics of your approach? Sure, not full how-to-do instructions - just few words about the main idea of the method.

Regards,
Fish.
Apr 25 '09 #3
mshmyob
904 Recognized Expert Contributor
Sure Fish.

Actually was quite easy to accomplish with AC2007.

The tables used in demo consisted of a Vendor Table and Product Table.

Main form for Vendor - subform Products.

DataSource for Subform

Expand|Select|Wrap|Line Numbers
  1. SELECT tblVendor.VendorID, tblProduct.ProductID, tblProduct.ProductDesc, tblProduct.ProdPrice, fProdPriceCondition(ProdPrice) AS PriceConditional FROM tblVendor INNER JOIN tblProduct ON tblVendor.VendorID=tblProduct.VendorID WHERE tblProduct.VendorID=Forms![frmColumnConditional].txtVendorID; 
  2.  

Module Code

Expand|Select|Wrap|Line Numbers
  1. Public Function fProdPriceCondition(dblPrice As Double)
  2.  
  3. 'this function is used to determine the background colour for the product price
  4. ' this is an example of how to change the colour of a single control on each row of a subform
  5. ' if under $10 1st conditional, 11 to 15 condition 2, 16 to 20 condition 3, 21 to 25 condition 4, 26 to 30 condition 5
  6.  
  7. Dim strDatabasePath As String
  8.  
  9. ' get the path where the bitmaps are stored
  10. strDatabasePath = CurrentProject.Path
  11.  
  12. ' change background colour of text price control (really changing an image control behind the text price control based on the value in the price field
  13. Select Case dblPrice
  14.     Case Is <= 10
  15.         fProdPriceCondition = strDatabasePath & "\red_price.bmp"
  16.     Case Is <= 15
  17.         fProdPriceCondition = strDatabasePath & "\pink_price.bmp"
  18.     Case Is <= 20
  19.         fProdPriceCondition = strDatabasePath & "\green_price.bmp"
  20.     Case Is <= 25
  21.         fProdPriceCondition = strDatabasePath & "\yellow_price.bmp"
  22.     Case Else
  23.         fProdPriceCondition = strDatabasePath & "\tan_price.bmp"
  24. End Select
  25.  
  26. End Function
  27.  
Simple enough so far - just a query to populate my subform and a function to show a simple condition.

The subform has a image (rectangular bitmap) behind the Price column. The price column is set to transparent background.

In Access2007 a new property for image controls is a Control Source (my control source is set to my function 'PriceConditional' - see query).

As you can see in my module I return the Control Source path to indicate which image to use behind each price.

All images are linked and NOTembedded in the table thereby not increasing the size of the database.

cheers,

@FishVal
Apr 25 '09 #4
FishVal
2,653 Recognized Expert Specialist
Nice solution. :)
Thank you.
Apr 25 '09 #5
mshmyob
904 Recognized Expert Contributor
Thank you.

cheers,

@FishVal
Apr 25 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
5490
by: Allan Koch | last post by:
Dear NG, I would like to format a record in a subform, dependent on a value in one field. If one field in the record I show in a subform (datasheet view) is true I like to view that particular...
1
2288
by: Carolyn | last post by:
I am trying to conditionally format an unbound field in an access form based on the value in another access field. The unbound field is actually the background to the form. I want users to be...
0
2020
by: Paul T. Rong | last post by:
I don't know why that I lost track of the post. I found it from the newsgroup and paste last two posts. Pieter Linden said: "To do this - use conditional formatting..." I didn' work it out....
2
8009
by: Jason | last post by:
I cant seem to get this to work! Basically, what I want to do is format some text boxes bases on the following: >0 to -4.99% = Green -5.00 to -7.99 = Yellow < -8.00 = Red I have used the...
1
4446
by: Martin Schneider | last post by:
Hi! I have an unbound text field conditionally formatted: =DomWert("";"ActiveLines") (DomWert is the german translation for domain value) (to check whether the currend record is within...
0
1408
by: Martin Schneider | last post by:
Hi! I'd like to set the 'enabled'-property for a checkbox depending on a conditional format. Unfortunately, the object doesn't feature a format condition. Is there a solution for this? ...
2
8598
by: Lyn | last post by:
Hi, Having fun trying to get Conditional Formatting working on a textbox control in a continuous form subform (Access 2003). The condition I want is when the value of the textbox is Null and/or...
16
1989
by: PCCTN | last post by:
I am building another data base for invoices. I have two tables on is for the invoices, one is for the parts. The invoice table contains several fields. for the customer info and for the orders...
1
1450
by: mattloflin | last post by:
Hey guys i'm kind of confused. I'm new to access but I've been getting a lot of progress. I have a form FRMDATABASE that is loaded into FRMSEARCH and frm search has a bunch of txtboxes that...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.