Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

item not in list error for a numeric value

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
ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"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.
Avatar of Fordraiders

ASKER

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
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
Just debug the code and step one line at the time ( F8)
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
Thanks very much ...