473,396 Members | 1,938 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,396 software developers and data experts.

If Then Else Problem

Hi i am trying to do the following code but it is saying i have an error "else without and if" but i do have an if below is the code
Expand|Select|Wrap|Line Numbers
  1. Private Sub StockDesc_Click()
  2.  
  3. If StockDesc = "Hard Hat" Then ExpiryDate.Visible = True
  4. If StockDesc = "Boots" Then ExpiryDate.Visible = True
  5. Else: ExpiryDate.Visible = False
  6. End If
  7. End Sub
thanks for any help
Jan 19 '12 #1

✓ answered by Rabbit

When you put the If expression Then expression code all on one line, it doesn't process any further.

You need to use this syntax instead.
Expand|Select|Wrap|Line Numbers
  1. if expression then
  2.    expression
  3. else
  4.    expression
  5. end if

3 1599
Rabbit
12,516 Expert Mod 8TB
When you put the If expression Then expression code all on one line, it doesn't process any further.

You need to use this syntax instead.
Expand|Select|Wrap|Line Numbers
  1. if expression then
  2.    expression
  3. else
  4.    expression
  5. end if
Jan 19 '12 #2
Thank you very much im supprised somthing like that affects it. Thanks again
Jan 19 '12 #3
NeoPa
32,556 Expert Mod 16PB
If it had worked that way, then the first If line would also have required an Else. Whichever way you look at it your code was going to fail there on one of them ;-)

Anyway, let me just remind you that post #2 is ripe for selection as Best Answer and please remember to post in the correct forum another time (You must have ignored one or two warnings this time to end up in the Articles forum).
Jan 19 '12 #4

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

Similar topics

4
by: Steven Stewart | last post by:
I have a database with an Employees table and a DataRecords table. It is a one-to-many relationship. Would it be possible to allow the Employees to enter their own records via the web using...
5
by: db2sysc | last post by:
ALl. Is it possible to get MS ACCESS CODING STANDARDS? TIA
45
by: Luvin lunch | last post by:
Hi, I'm new to Access and have been asked to develop a simple Access system to replace one that already exists. There are five users of the current Access system and each of the users works off...
1
by: shades234 | last post by:
if this isn't in the right place, would someone be kind enough to either move it, or direct me where to post. thanks Now, i have a form in MS Access2003. i removed the navigation buttons and...
2
by: OldSchool | last post by:
Guys, Thanks for the Reply i recieved from one of our Buddy here in Community. Question REgarding Coding of VB6 and Access 1. Are they same when it comes to Coding? 2. Can i Copy and Paste...
14
by: ApexData | last post by:
I am considering building some distributable commercial applications. For about a year now, I have been using Access2000. This was my first venture into object oriented database development. ...
2
by: oh4real | last post by:
Howdy all. I have pretty much NO VB/Access coding experience, but am forced to come up with a generic script/process for users with varying database designs and varying levels of expertise to use...
1
by: rojas | last post by:
I need to convert an Access 2002 application to VB. Does any know of a good converter that would save me time? Not necesseraly that it would be a perfect converter, but one that would save me hours...
4
by: beckycarter04 | last post by:
I have built a form database and it is linked to a phone caller ID system. I need a validation IF code that is "if the caller id prefix starts with a 613476 than it screen pops a "Quinte territory"...
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: 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
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
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
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
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.