473,803 Members | 3,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with If/Then/Else code

22 New Member
I have a form with a tabbed control on it. I am trying to set certain criteria for some of the tabs to show only when info from other fields meet criteria.

Specifically, I have two fields. Both are combo boxes (using tables as the row source).

What I want is that when empType combo box is set to Prehire (8 in the table) AND the empPosition combo box is set to Police Officer then the Police_MSK tab is visible. But if both of those conditions aren't met then I don't want that tab showing.

What might complicate this is that for all other Prehires (non Police Officer's) I have a different tab that I want to be visible called Prehire_MSK.

Here is what my code looks like:

Expand|Select|Wrap|Line Numbers
  1. Private Sub empType_AfterUpdate()
  2.  
  3.  If Me.empType = "8" Then
  4.         Me.Prehire_MSK.Visible = True
  5.     Else
  6.         Me.Prehire_MSK.Visible = False
  7.     End If
  8.  
  9.  If Me.empType = "8" And Me.empPosition = "Police Officer" Then
  10.         Me.Police_MSK.Visible = True
  11.     Else
  12.         Me.Police_MSK.Visible = False
  13.     End If
  14.  
  15. End Sub
So after updating the empType field to Prehire I get the Prehire_MSK tab to show up and when I change that field to any other type the Prehire_MSK tab goes away like it's supposed to.

But it doesn't seem to be looking at the empPosition field and I can't get the Police_MSK tab to show up when it is a Prehire Police Officer. Can someone help me and tell me what's wrong with my code?

Am I better off using a Select Case instead of the If/Then/Else?

I hope I explained well enough what my problem is...

Thanks!
Nov 9 '09 #1
2 2103
MMcCarthy
14,534 Recognized Expert Moderator MVP
I think your problem is in your logic. Try this instead ....

Expand|Select|Wrap|Line Numbers
  1. Private Sub empType_AfterUpdate()
  2.  
  3.     If Me.empType = "8" And Me.empPosition = "Police Officer" Then
  4.         Me.Police_MSK.Visible = True
  5.         Me.Prehire_MSK.Visible = False
  6.     ElseIf Me.empType = "8" Then
  7.         Me.Police_MSK.Visible = False
  8.         Me.Prehire_MSK.Visible = True
  9.     Else
  10.         Me.Police_MSK.Visible = False
  11.         Me.Prehire_MSK.Visible = False
  12.     End If
  13.  
  14. End Sub
Nov 9 '09 #2
rleepac
22 New Member
Thank you that is much "cleaner" logic.

I figured out my problem...I was using Police Officer where I should have been using the ID number from the table that is was using as a row source.

Problem solved!

Thanks again...
Nov 9 '09 #3

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

Similar topics

0
1643
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set the image for the checkbox portion so that the control conforms to my site's visual style, and that lets me set the style for the text in both the enabled and disabled states. As you might expect, I couldn't find one. So I decided to roll my own.
2
4456
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c */ #include <time.h>
11
2117
by: felixnielsen | last post by:
What i have is not even a real problem, but i hope someone can help anyway, but first a piece of code_ @code start const unsigned short Size = 2; // 2^N std::bitset<Size*Size*Size> YZ; std::bitset<Size*Size*Size> XZ; std::bitset<Size*Size*Size> XY; std::bitset<Size*Size*Size> V; union {
18
3351
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
8
2458
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the report. I never see the code going to my error handling on the button. If I debug, I am in an...
2
1576
by: darrel | last post by:
Hi there vb masters i have a problem regrading the saving procedure in my program: Here my code: Private Sub cmdSave_Click() Dim rsShowRec As New ADODB.Recordset Dim cnn As New ADODB.Connection Set cnn = New ADODB.Connection
10
4409
by: amitabh.mehra | last post by:
Hi I havent used MQT before. Read the online tips and tutorials but none seems to give any hint for my problem. I have a base table (base_table) as: st varchar(25) default 'my_null' dt timestamp default '1900-01-01-00.00.00.00000'
9
2723
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i have face problem that is if i insert 6 at 3 this value is not insert at 3 it insert last positon i.e after last value .In given example the value is appned or insert after 5 then output is 12456 but i have want the output 12645 and i also give the...
1
2322
kiemxai
by: kiemxai | last post by:
you see that,i did correct or not? PROBLEM ANALYSIS For an introduction to program transaction journal, see the background section of assignment . Not only transaction journal, but also inventory sheet is needed to print at the end of the day. It is the list of items, inventory cost, inventory units, and inventory amount When items of the same type were purchased at different unit cost, it is the question as to how to calculate the unit...
23
3603
by: ryna | last post by:
Desperately need help.... here's the snippet of my code that im trying to solve since last week... icePayment.aspx If (Left(Request.Form("return_url"), 7) <> "http://") Then errorInput = errorInput & "Invalid return URL path! <BR>" errorExist = True Response.Redirect("InvalidUrlError.aspx")
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
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...
1
7600
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
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();...
1
4274
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
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
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.