item not in list error for a numeric value

Fordraiders
Fordraiders used Ask the Experts™
on
item not in list error for a numeric value
I HAVE A DROPDOWN BOX.

The following code works fine but if someone accidentally types in just a "numeric" (5)  AND hits enter an error occurs.
-2473
Out of stack space  


Dim str As String
Dim errYes As Boolean
    
errYes = False
NewData = RemoveSpaces(NewData)
str = Trim(NewData)


If errYes = False Then
   If Len(str) >= 5 Then
      errYes = True
      MsgBox "You Have Copied Data On Top Of Other Data Or The Track Code Is Not In The List. Please Double Check Your Entry."
      Response = acDataErrContinue
      Exit Sub
   End If
End If

Me.cbo_Track_Code.Text = str
Response = acDataErrContinue

Open in new window


Is there a way to amend this code or trap the error and resume ?

Thanks
ordraiders
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
Commented:
How about an Error Handler and debugging the code to find out the exact point where the error happens.
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012

Commented:
"out of stack space" means you in a loop calling procedures over and over.

Put a breakpoint on a line, then step through with F8.   Should be pretty obvious.

 and as John said, add some error handling, although that's not going to help with this error.

Jim.

Author

Commented:
ok now it seems i'm in an endless loop ?




Dim str As String
Dim errYes As Boolean
   
On Error GoTo cbo_Track_Code_NotInList_Error
   
errYes = False
NewData = RemoveSpaces(NewData)
str = Trim(NewData)


If errYes = False Then
   If Len(str) >= 5 Then
      errYes = True
      MsgBox "You Have Copied Data On Top Of Other Data Or The Track Code Is Not In The List. Please Double Check Your Entry."
      Response = acDataErrContinue
      Exit Sub
   End If
End If

Me.cbo_Track_Code.Text = str
Response = acDataErrContinue

On Error GoTo 0
   Exit Sub
   
   
cbo_Track_Code_NotInList_Error:
Select Case Err
        Case 2467 'ODBC down
            MsgBox "Your VPN Connection May be down or The Redbook Tool Is Not Locked/Not Responding!", vbCritical
        ' go back to the line of code that caused the problem
              Exit Sub
        Case 2473 'No item in list
            MsgBox "You Have entered an Item not in the List."
       
            Exit Sub
        Case Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ") in Seller Track Code Escalation option   of Form_Main"
       
            Exit Sub
End Select
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
this even even throwing me in a loop ?

Private Sub cbo_Track_Code_NotInList(NewData As String, Response As Integer)
Dim str As String
Dim errYes As Boolean
   
On Error GoTo cbo_Track_Code_NotInList_Error
   
errYes = False
NewData = RemoveSpaces(NewData)
str = Trim(NewData)


If errYes = False Then
   If Len(str) >= 5 Then
      errYes = True
      MsgBox "You Have Copied Data On Top Of Other Data Or The Track Code Is Not In The List. Please Double Check Your Entry."
      Response = acDataErrContinue
      Exit Sub
   End If
End If

Me.cbo_Track_Code.Text = str
Response = acDataErrContinue

ExitHere:
   Exit Sub
   
   
cbo_Track_Code_NotInList_Error:
  MsgBox "error here"
  Resume ExitHere
 
End Sub
John TsioumprisSoftware & Systems Engineer

Commented:
Just debug the code and step one line at the time ( F8)

Author

Commented:
i just end up putting in standard error control check
but added this because the numeric was causing a issue.
The value is always a alphanumeric sequence.

If IsNumeric(str) Then
   MsgBox "Entered a Value that is not in the List"
   Me.cbo_Track_Code.Text = ""
   Me.cbo_Track_Code.SetFocus
   Exit Sub
Else
Me.cbo_Track_Code.Text = str

End If

Author

Commented:
Thanks very much ...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial