if then else problem

  • Thread starter Thread starter Pierre
  • Start date Start date
P

Pierre

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
 
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.
 
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.)
 
You also have the following line:

Else: GoTo nochoice

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

stupid of me, it was indead the : (colon)
thanks for your help,
Pierre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top