Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default if then else problem

Hi,

can anybody tell me what is wrong in this snippet of code ?

If search_acc.Value < " " Then
result = search_acc.Value
Column = 23
ElseIf search_status < " " Then
result = search_status.Value
Column = 176
Else: GoTo nochoice
End If
.....
various code
.....
nochoice:
msgbox "you did not make a choice, make a choice !"


Where search_acc and search_status are comboboxes
Whatever you do, you allways end up with the messagebox from nochoice:
Please help !
Thanks,
Pierre


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default if then else problem

Try using "" instead of " ".

--
Dan

On Dec 20, 12:44 pm, "Pierre" wrote:
Hi,

can anybody tell me what is wrong in this snippet of code ?

If search_acc.Value < " " Then
result = search_acc.Value
Column = 23
ElseIf search_status < " " Then
result = search_status.Value
Column = 176
Else: GoTo nochoice
End If
....
various code
....
nochoice:
msgbox "you did not make a choice, make a choice !"

Where search_acc and search_status are comboboxes
Whatever you do, you allways end up with the messagebox from nochoice:
Please help !
Thanks,
Pierre

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default if then else problem

Should This:
If search_acc.Value < " " Then
be this:
If search_acc.Value < "" Then

Unless you deliberately put the space between the double quotes for clarity
in this posting, it probably would not work well in your code unless you have
single spaces entered in your combobox. If you are testing for null then,
there should be no space between the quote marks.

Also, it is not good practice to use reserved names like Column for
variables. That can produce undesirable results too.

"Pierre" wrote:

Hi,

can anybody tell me what is wrong in this snippet of code ?

If search_acc.Value < " " Then
result = search_acc.Value
Column = 23
ElseIf search_status < " " Then
result = search_status.Value
Column = 176
Else: GoTo nochoice
End If
.....
various code
.....
nochoice:
msgbox "you did not make a choice, make a choice !"


Where search_acc and search_status are comboboxes
Whatever you do, you allways end up with the messagebox from nochoice:
Please help !
Thanks,
Pierre



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default if then else problem

What line of code do you have on the line immediately above the line label
"nochoice:"?

You should have an Exit Sub or something to make sure you jump around the
MsgBox. (I'm assuming that the MsgBox after "nochoice:" is right at the end
of the routine, like an error handler.)
--
Regards,
Bill Renaud



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default if then else problem

You also have the following line:

Else: GoTo nochoice

There should not be a colon (:) after the Else.

--
Regards,
Bill Renaud





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default if then else problem

Hi Bill,

stupid of me, it was indead the : (colon)
thanks for your help,
Pierre
"Bill Renaud" schreef in bericht
. ..
You also have the following line:

Else: GoTo nochoice

There should not be a colon (:) after the Else.

--
Regards,
Bill Renaud





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 05:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"