Run Time error 3077

B

Bongard

I have a combo box in a form that allows a user to type in a loan
number and on enter the form then pops up the information on that loan.
However, if the incorrect loan number is typed in I get the run time
error 3077 "Syntax error (missing operator) in expression." I have the
feeling the users of this database will be startled if this happens and
would like to avoid that error if at al possible and replacy it with a
more friendly message box. Here's a look at my code

Private Sub Combo31_AfterUpdate()
' Find the record that matches the control.
'MsgBox "No Matching Records"
'Select Case Err.Number
'Case Is = 3077
'MsgBox "There are no loans matching the loan number entered"
'Case Is <> 3077
Me.RecordsetClone.FindFirst "[Loan Number] = " &
Me.Combo31.Column(0)
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Select

You can see that i tried to match the case number and display a message
box if this was the error but that didn't work(commented out). Also, if
the user keys in the correct loan number this combo box works just
fine.

Any ideas?

Thanks!
 
D

Douglas J. Steele

If you're going to work with the Error number, you need to ensure that your
program knows what to do when it encounters an error. This is done by
putting an

On Error ...

statement at the top of the routine.

See whether this does what you want:

Private Sub Combo31_AfterUpdate()
On Error GoTo Err_Combo31_AfterUpdate

Me.RecordsetClone.FindFirst "[Loan Number] = " & Me.Combo31.Column(0)
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End_Combo31_AfterUpdate:
Exit Sub

Err_Combo31_AfterUpdate:
Select Case Err.Number
Case 3077
MsgBox "There are no loans matching the loan number entered"
Resume Next
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") occurred."
Resume End_Combo31_AfterUpdate
End Select

End Sub
 
B

Bongard

Wow I really appreciate that Doug, thanks for your help. As soon as the
code was posted into VB it worked perfectly! That makes sense to me
now.

That case is correct right, I would use the 3077?

Thanks for your help!

-Brian
 
D

Douglas J. Steele

You'd use whatever error it is you're trying to avoid. If it's supposed to
be a different number, you'll know! <g>
 

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


Top