Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel macro crashes if an entry in a combo box is not in the list

I am using a combo box on a form to find a part in a list, if the combo is
left empty a message is displayed. the code is as follows
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
But if I enter a number not on the list, the debug window pops up.
I can not seem to find the syntax to say 'If the combo value finds no match
then show error message'.
I would think it is just a case of putting the 'no match' in place of the ""
I am greatful for any pointers.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Excel macro crashes if an entry in a combo box is not in the list

Have you looked at

Debug.print "Value: ";Me.cboPart.Value
Debug.print "Length: ",Len(Me.cboPart.text) 'Not sure if this will work
Debug.print "Trim: ", Trim(Me.cboPart.Value)
Debug.print "IsEmpty", ISEMPTY(Me.cboPart) 'Not sure if this will work

This may help you figure out what the problem is.
--
HTH,
Barb Reinhardt



"Mike DFR" wrote:

I am using a combo box on a form to find a part in a list, if the combo is
left empty a message is displayed. the code is as follows
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
But if I enter a number not on the list, the debug window pops up.
I can not seem to find the syntax to say 'If the combo value finds no match
then show error message'.
I would think it is just a case of putting the 'no match' in place of the ""
I am greatful for any pointers.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel macro crashes if an entry in a combo box is not in the list

If you change your ComboBox's Style property to 2-fmStyleDropDownList, your
user will not be able to type in anything unless it is in the list.

Rick


"Mike DFR" wrote in message
...
I am using a combo box on a form to find a part in a list, if the combo is
left empty a message is displayed. the code is as follows
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
But if I enter a number not on the list, the debug window pops up.
I can not seem to find the syntax to say 'If the combo value finds no
match
then show error message'.
I would think it is just a case of putting the 'no match' in place of the
""
I am greatful for any pointers.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel macro crashes if an entry in a combo box is not in the l

Rick
Your suggestion stops the crash, but the user is stuck, I need to go from
here to adding a message box an resetting, (reset the combo focus)
Thanks so far.

"Rick Rothstein (MVP - VB)" wrote:

If you change your ComboBox's Style property to 2-fmStyleDropDownList, your
user will not be able to type in anything unless it is in the list.

Rick


"Mike DFR" wrote in message
...
I am using a combo box on a form to find a part in a list, if the combo is
left empty a message is displayed. the code is as follows
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
But if I enter a number not on the list, the debug window pops up.
I can not seem to find the syntax to say 'If the combo value finds no
match
then show error message'.
I would think it is just a case of putting the 'no match' in place of the
""
I am greatful for any pointers.



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
LIST ENTRY ENABLE DROP DOWN LIST TO ACCEPT MORE THAN 1 ENTRY Frank Excel Discussion (Misc queries) 2 September 18th 08 10:31 PM
Combo Box that allows user entry of values not on drop-down list donnadelayed Excel Discussion (Misc queries) 1 July 2nd 08 04:20 PM
select macro within combo box or list box to Karin Excel Discussion (Misc queries) 2 June 25th 08 01:49 AM
What happened to my Macro entry in the Excel 2003 Tool menu list? Mr. Clean Setting up and Configuration of Excel 0 December 11th 07 05:54 PM
Excel crashes when Combo Box loses focus ExcelEddie Excel Programming 1 May 17th 06 08:50 PM


All times are GMT +1. The time now is 07:30 PM.

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

About Us

"It's about Microsoft Excel"