473,402 Members | 2,061 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,402 software developers and data experts.

If...Elseif...Else...Endif question

40
I'm having a wierd difficulty with my If...ElseIf...Else...End If statement.

I'm having the db put together a string to base a recordset off of, and depending on the ID number, the select statement changes.

Basically it looks like this:

Expand|Select|Wrap|Line Numbers
  1. If Me.ProjectID.Value <=1835 Then
  2. str = _Select statement 1
  3.  
  4. ElseIf 1836 <= Me.ProjectID.Value <= 5109 Then
  5. str = _Select statement 2
  6.  
  7. Else
  8. str = _Select statement 3
  9.  
  10. End if
  11.  
  12. Set DB = CurrentDB
  13. Set rst = DB.OpenRecordSet(str)
For IDs under that fit under the first two conditions, the code works fine, but when it falls under the last "else" condition, it doesn't register for some reason.

Am I doing something wrong in this statement?
Oct 4 '07 #1
1 2806
missinglinq
3,532 Expert 2GB
Your problem, I think, is in your line

ElseIf 1836 <= Me.ProjectID <= 5109 Then

It should be

ElseIf 1836 <= Me.ProjectID And Me.ProjectID <= 5109 Then

As you have it set up, there is no 3rd condition; you have

Me.Project <=1835

and

Me.Project >=1836

Linq ;0)>
Oct 4 '07 #2

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

Similar topics

7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
6
by: Ivan Sergio Borgonovo | last post by:
First thanks to Tom Lane who helped me promptly. Now let's come to the problem: create or replace function testa( ) returns char(32) as ' begin if 1=2 then if 1=2 then
0
by: Fabio R. | last post by:
I'm going crazy... Can someone help me to do a regex to search for something like nested if? I have these tags: <if>...<else>...<endif> that can be nested: <if> <if>...<else>...<endif>
2
by: paul | last post by:
Hi all, I've been handed some code and, unless I've got the numbering of parentheses wrong, one of the functions has a curious if-else statement. The thing compiles but is it right? I know the...
3
by: Mr. Ken | last post by:
In the file I received, it defines two versions of same function with such statement. Is it during compilation, func1 will be used? #if 1 func1..... #else func1..... #endif
25
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example...
3
by: amrhi | last post by:
Hy guys , I try to make conditional statement by using if and elseif . the problem are if i use 2 conditional statement the script run well but if try add more conditinal statement it's not working...
17
by: JRough | last post by:
I'm trying to get error proof code. I have this code which seems to work but now I look at it I think it should be elseif not else and I wonder why it works. It is in the block:...
13
by: scottbouley | last post by:
HELP! I'm trying to check a form for missing values. Two of the fields are required and therefore the corresponding message boxes are VBOkOnly. The other two are for warning purposes and their...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
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.