Solved

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

Posted on 2010-08-27
8
575 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
ID: 33541632
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
ID: 33541712
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
ID: 33541756
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33541804
What that be "onLoad"?

I'd be interested in this too!
0
 

Author Comment

by:Saleve
ID: 33541845
Format > Conditional Formatting (in Access 2003)
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 33541894
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
ID: 33541896
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
ID: 33541933
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 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