Solved

Can I use VBA to do conditional formatting in an Access 2003 form?

Posted on 2010-08-27
8
547 Views
Last Modified: 2013-11-28
Hello,
I have about 15 conditions to consider in the formatting of a particular text box on a form.  Since the Conditional Formatting on the menu bar allows a maximum of three conditions, I would like to know if I can get around this by using VBA.

Thank you.
0
Comment
Question by:Saleve
8 Comments
 
LVL 13

Expert Comment

by:lucas911
Comment Utility
Sure you can try select case statement
Private Sub FormatBox(intFormatType as integer)



Select case intFormatType

CASE 1:

  Me.txtTextBox.BackColor = RGB(255, 255, 66)

  Me.txtTextBox.FontBold = True

CASE 2:

  Me.txtTextBox.BackColor = RGB(63, 25, 66)

  Me.txtTextBox.FontBold = False

CASE Else

  Me.txtTextBox.BackColor = RGB(255,255,255)

  Me.txtTextBox.FontBold = False

End Select



End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:INHOUSERES
Comment Utility
could also use these (if it's a number):

Case Is Between 1 and 6
Case Is >3
Case Is <=4
0
 

Author Comment

by:Saleve
Comment Utility
Actually, I have a continuous form and each record needs to be considered separately.  That's the difficulty.  Is it possible in VBA or are we limited to the menu function to do this?
0
 
LVL 5

Expert Comment

by:INHOUSERES
Comment Utility
What that be "onLoad"?

I'd be interested in this too!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Saleve
Comment Utility
Format > Conditional Formatting (in Access 2003)
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
Unfortunately, not in a continuous form (in 2003).  However, this is possible in 2007, if that helps any.
0
 
LVL 5

Expert Comment

by:INHOUSERES
Comment Utility
I'm aware of the conditional formatting.
Knowing how do to something to a textbox individually for a continuous form might NOT be possible.

I'm hoping, like you are, that an expert knows of a way.
0
 

Author Closing Comment

by:Saleve
Comment Utility
I was afraid of that.  I'm going to look into upgrading.  It's about time (although it's not up to me...).

Thanks.
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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 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

7 Experts available now in Live!

Get 1:1 Help Now