473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

If statement problem in module

I want my code to change the back colour to red (of a form field) if
the name is either "admin" or "meeting" or "holiday".

I tried this;

If rs!ACCOUNTNAME = "Meeting" Then
f("text" & i).BackColor = 255
ElseIf rs!ACCOUNTNAME = "Holiday" Then
f("text" & i).BackColor = 255
ElseIf rs!ACCOUNTNAME = "Admin" Then
f("text" & i).BackColor = 255

This works for all "Meeting" named fields but not the second or third
statements. I then thought I would be able to do an If / Or statement;

ElseIf rs!ACCOUNTNAME = "Holiday" Or "Meeting" or "Admin" Then
f("text" & i).BackColor = 255

But this creates an error. What am I doing wrong?

Dec 10 '06 #1
1 1450
On 10 Dec 2006 02:34:48 -0800, "keri" <ke*********@diageo.comwrote:

It should be:
elseif x=1 or x=2 or x=3

Or alternatively:
select case x
case 1,2,3:
y.backcolor = vbRed
case else
y.backcolor = vbGreen
end select

Use the debugger to set a breakpoint at the top of your function, and
then step through, inspecting values, etc. Then programming gradually
is not such a mystery anymore.
You can also add temporary code such as:
debug.print i, y(i).backcolor
so you can easily review the color assignments.
I speculate that the "missing colors" occurs because a color is
"overwritten" in one of the next iterations.

-Tom.

>I want my code to change the back colour to red (of a form field) if
the name is either "admin" or "meeting" or "holiday".

I tried this;

If rs!ACCOUNTNAME = "Meeting" Then
f("text" & i).BackColor = 255
ElseIf rs!ACCOUNTNAME = "Holiday" Then
f("text" & i).BackColor = 255
ElseIf rs!ACCOUNTNAME = "Admin" Then
f("text" & i).BackColor = 255

This works for all "Meeting" named fields but not the second or third
statements. I then thought I would be able to do an If / Or statement;

ElseIf rs!ACCOUNTNAME = "Holiday" Or "Meeting" or "Admin" Then
f("text" & i).BackColor = 255

But this creates an error. What am I doing wrong?
Dec 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
9
by: Michele Simionato | last post by:
Is there a way of "ending" a module? I would like something like this: # mod.py print 'something here' end() # some mysterious function print 'you should not get here' # main.py import mod...
11
by: Paul Rubin | last post by:
I frequently find myself writing stuff like # compute frob function, x has to be nonnegative x = read_input_data() assert x >= 0, x # mis-use of "assert" statement frob = sqrt(x)...
6
by: David | last post by:
I am using ADO to run some SQL statements in Access. First, I run query to create a table using SELECT . . . INTO Table A. Then, I run a query to SELECT . . . FROM Table A to get some data and...
5
by: | last post by:
I have a module that's processed as an include file in a tradtional asp application that I'm migrating to dotnet. In one of the modules, there's an if statement that's gotten appended to over...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
7
by: Chris Lasher | last post by:
Hi all, I have a simple script: --- #!/usr/bin/env python a = 1 b = 2
3
by: kwatch | last post by:
What is the condition of module name which is available in 'from .. import ..' statement ? ---------------------------------------- import os print os.path # <module 'posixpath'...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.