473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,398 developers and data experts.

Demo of Conditional format in subform - Unlimited colours

mshmyob
904 Expert 512MB
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, 1289 views)
Apr 24 '09 #1
5 9582
NeoPa
32,556 Expert Mod 16PB
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 Expert 2GB
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 Expert 512MB
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 Expert 2GB
Nice solution. :)
Thank you.
Apr 25 '09 #5
mshmyob
904 Expert 512MB
Thank you.

cheers,

@FishVal
Apr 25 '09 #6

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

Similar topics

6
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.