Clickable Button

C

Curtis Stevens

I have this code as an onclick event for a button, but it is now crashing all
of a sudden for me when using it half the time.

On Error GoTo handler
Dim Msg, Style, Title, Response, MyString
Msg = "Run Update Query?"
Style = vbYesNo + vbDefaultButton1 + vbExclamation
Title = "Run Update Query?"

Response = msgbox(Msg, Style, Title)
If Response = vbYes Then '

DoCmd.SetWarnings False
DoCmd.OpenQuery "UpdateAppEntry"
DoCmd.SetWarnings True

Else
End If
handler:
If Err.Number = 2498 Or 94 Then
End If
End Sub

==========================

UpdateAppEntry - is an update query

Any ideas or suggestions?

Curtis
 
B

BruceM

A couple of things I noticed (I don't know if they matter):
If Err.Number = 2498 Or 94 Then
needs to be
If Err.Number = 2498 Or Err.Number = 94 Then

On another point, what is supposed to happen if the error number is
something other than 2498 or 94? I would think the application could hang
if the error number is other than one of those two.

Try adding something like this before the handler line:

ProcExit:
Exit Sub

Then in the error handler, something like:

Select Case Err.Number
Case 2498, 94
Resume ProcExit
Case Else
MsgBox "Error #" & Err.Number & "(" & Err.Description & ") in
Procedure Name"
End Select
Resume ProcExit

Substitute the name of your procedure at the end of the MsgBox line.

On another point (unrelated to the current difficulties), you don't really
need Else in the code unless there is an Else condition.
 
C

Curtis Stevens

Bruce,

Ok, I tried this code & same thing. This is what I'm doing.

I have a box I check on the form that makes a field in the table YES, which
is a criteria for this update query to run. So when I select the check box
and click the button, it asks me to run it, I click yes and then scroll to
another record, but if I scroll back to the original record too fast, it
crashes! But if I wait a second or two, it doesn't....

Curtis
 
D

Damon Heron

There is nothing wrong with this code, so the problem must be in the query.
Where is it crashing?

Damon
 

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

Top