473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple IF ElseIF statements not working

3 New Member
Hello all,

I'm trying to get multiple IF, THEN statements to work. Based on several examples, I believe it is coded properly, however, when I execute the code, nothing happens with the exception of one condtion.

Here's the code and condition:

Expand|Select|Wrap|Line Numbers
  1.     If Exterior.Value = "Snow Hauling" And Me.statecmbo <> "" And Me.zipcmbo <> "" Then
  2.         Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Vendor Zip] Like '" & Nz(zipcmbo.Value, "") & "*' And [Snow Hauling] Like '" & Nz(Yes) & "*'"
  3.         Me.FilterOn = True
  4.  
  5.     ElseIf Exterior.Value = "Complete Lawn Care" And Me.statecmbo <> "" And Me.zipcmbo <> "" Then
  6.             Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Vendor Zip] Like '" & Nz(zipcmbo.Value, "") & "*' And [Complete Lawn Care] Like '" & Nz(Yes) & "*'"
  7.             Me.FilterOn = True
  8.     End If
The only time it works, is when state = ND, zip = 58102 and the exterior value = complete lawn care. When I put in other combinations that should produce results, nothing happens.

Any help is appreciated.
Apr 14 '10 #1
4 4738
NeoPa
32,570 Recognized Expert Moderator MVP
That seems weird. Have you tried other non-blank values for [StateCmbo] & [ZipCmbo] with [Exterior] still "Complete Lawn Care"?
Is [Exterior] a ComboBox or ListBox control (Operator freehand is not advised to match up with existing names)?
Apr 15 '10 #2
formsrtuff
3 New Member
Exterior is a combobox. i actually shortened the code:
Expand|Select|Wrap|Line Numbers
  1. If Exterior.Value = "Snow Hauling" And Me.statecmbo = "PA" Then
  2.   Me.Filter = [Vendor State] = Me.statecmbo
  3. Else
  4.   DoCmd.OpenForm "switchboard", acNormal
  5. End If
When I execute the search, nothing happens, not even the Else statement. So now, I'm really confused.

Any insight is appreciated.
Apr 15 '10 #3
formsrtuff
3 New Member
Just stumbled on something. When all the fields are Null, and I click on the search button, the switchboard opens. Strange.
Apr 15 '10 #4
NeoPa
32,570 Recognized Expert Moderator MVP
Reducing posted code can be a good idea when you know you are removing stuff which is not relevant to the problem. In this case that doesn't appear to be the case. Your second set of code bears little or no resemblance to the first, so instead of clarifying the situation it merely makes trying to work out what you're about so much harder.

As your latest code has a line that cannot possibly compile even, it seems to me that a good place to start would be for me to dig up some basic starting point ideas that will help you put down a question we can start to work on.
When posting any code on here please :
  1. Ensure you have Option Explicit set (See Require Variable Declaration).
  2. Try to compile it. If it doesn't compile for any reason please explain that clearly - including the error message and which line of your code it appears on. Compilation is done from the Visual Basic Editor menu - Debug \ Compile Project (Where Project is the actual name of your project).
  3. Copy your code (using the Clipboard - Cut / Copy / Paste) from your project directly into your post. Typing in code is not appreciated as it is likely to introduce typos which cause members to waste their time unnecessarily.
  4. Ensure that the code in your post is enveloped within CODE tags. The hash (#) button in the posting page helps with this. Simply select your code and click on the hash button to have it enveloped automatically.
If all these points are covered then all members will be better able to understand, and therefore attempt to answer, your question.
Apr 15 '10 #5

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

Similar topics

4
16758
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from customers; I can execute each statement individually but get the 'you have an error in
2
3129
by: Annie D via AccessMonster.com | last post by:
Hi, Is it possible to use multiple statements in SQL?? (I’ve never used it before) : I have one query that i'm working with, The statements I want to use are as below, they all work individually, but not together, Access help is as much use as a chocolate fireguard in this case! any suggestions or explainations would be gratefully appreciated:
5
2035
by: Leon | last post by:
Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a better way")? Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click If Page.IsValid Then If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
3
2207
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 only 2 conditional it select. thanks to help me my script //condtional// if ($ttl_dur > 10 and $bay!=$stand and $dpt_reg==0){ $fail=1; }elseif($ttl_dur > 15 and $bay==$stand and categori==0){ $fail=1; ...
6
6894
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different people and user should be able choose the check boxes to whom they want to send e mail to. I write some code simple If else conditions but i think i am making some mistakes. Because when i tried - it is not sending them e mails. Here is my code. I...
2
5154
by: dozingquinn | last post by:
Hello, I'm new to the world of VBA & Access (2000), so I really don't know that much. I am trying to setup a VBA multiple if statement for a new field and would really appreciate some help and pointers in the right direction. Essentially, the statement is designed to look up the payment frequency entered, then divide and multiply the expense field accordingly. Is this the best way of going about it? If = "1 week" then
0
3119
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
0
1275
by: jhop | last post by:
Hello everyone, I am having a slight problem with a program i am working on for a class, I am using Visual Studio 2005. The program only allows the up arrow key as input. In the code it is set up that one tap of the key will highlight (change the back color) of the next button, and that a double tap of the key will be like a mouse click and select that button. Most of the buttons will lead to new forms being displayed. At the moment I...
3
1483
by: tragic54 | last post by:
Alright so im having a problem getting a value from a couple combo boxes based on their index. Im calling the objects from the main form to calculatecost() from 2 other classes. Anyways heres the main form code and i'll post one class after that with the combo box selected values. Option Strict On Option Explicit On Public Class MobilePhoneCost Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As...
4
2409
by: henry | last post by:
Folks: As a follow-up to my recent posts, I want to ask some more general questions about multiple instances of a CSS link in a page as seen by browsers due to server-side file inclusion. Let me set up my question by providing skeleton code for two files: Here's a skeleton of "index.php": <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
0
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.