Save doesn't fire, but does when a breakpoint is set (1 Viewer)

Matty

...the Myth Buster
Local time
Today, 12:24
Joined
Jun 29, 2001
Messages
396
I'm running into a weird problem and I was wondering if anyone else has come across it. I load my larger forms at startup, so when the user clicks the Exit button on a form, I just make it invisible. In that click event, I also check to see if there are unsaved changes. If there are (and the user chooses to save them), I call the cmdSave_Click event before making the form invisible.

The problem I'm running into is that the record doesn't save when I call the cmdSave_Click event. But when I set a breakpoint at that event, and I just click continue when it hits the breakpoint, the save works.

I was just wondering if anyone else has had this problem, and if so, how did you fix it?
 

Fizzio

Chief Torturer
Local time
Today, 18:24
Joined
Feb 21, 2002
Messages
1,885
post the code on the exit button and the save button.
 

Matty

...the Myth Buster
Local time
Today, 12:24
Joined
Jun 29, 2001
Messages
396
Code:
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click

'Adds record to log
    Call intAddLogRecord("Referral Form -- exit button clicked -- RefNumber " & txtRefNumber)

'Checks for unsaved changes. If some are found, the user is prompted to save them
    Dim intResponse As Integer
    If Me.Dirty = True Then
        intResponse = MsgBox("There are unsaved changes. Would you like to save them?", _
        vbYesNoCancel, "Unsaved Changes")
        
        Select Case intResponse
            Case 6
                Call cmdSave_Click
                
            Case 7
                Call cmdUndo_Click
                
        End Select
    End If
    
    If Me.Tag <> "" Then
'Makes form that opened Referral visible
        Me.AllowAdditions = True
        Forms(Me.Tag).SetFocus
        DoCmd.Maximize
        Forms(Me.Tag).Visible = True
        Me.Visible = False
        Me!cmdNewReferral.Visible = False
    End If
    
Exit_cmdExit_Click:
    Exit Sub

Err_cmdExit_Click:
'Adds record to log
    Call intAddLogRecord("Referral Form -- exit error: " & Err.Description & " -- RefNumber " & txtRefNumber)
    Resume Exit_cmdExit_Click
    
End Sub
Code:
Private Sub cmdSave_Click()
'Saves referral and address record
On Error GoTo Err_cmdSave_Click
    DoCmd.Hourglass True

'Adds record to log
    Call intAddLogRecord("Referral Form -- save button clicked -- RefNumber " & txtRefNumber)

    Call SetAddress(Me)
    DoCmd.RunCommand acCmdSaveRecord
    
    DoCmd.Hourglass False
Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    DoCmd.Hourglass False
'Adds record to log
    Call intAddLogRecord("Referral Form -- save error: " & Err.Description & " -- RefNumber " & txtRefNumber)
    Resume Exit_cmdSave_Click
    
End Sub
 

Fizzio

Chief Torturer
Local time
Today, 18:24
Joined
Feb 21, 2002
Messages
1,885
Have you tried with the error checking off to see if you are creating an error? and what does the SetAddress(Me) Sub do.

If it is a long sub, you may benefit from a DoEvents statement just before the SaveRecord Command.
 

Mile-O

Back once again...
Local time
Today, 18:24
Joined
Dec 10, 2002
Messages
11,316
Fizzio said:
Have you tried with the error checking off to see if you are creating an error?

His error log should be reporting that! ;)
 

Fizzio

Chief Torturer
Local time
Today, 18:24
Joined
Feb 21, 2002
Messages
1,885
Mile-O-Phile said:


His error log should be reporting that! ;)
Yep I know, but does he actually check it???
And of course it gives him the opportunity to see Access' "helpful" messages:p
 

Matty

...the Myth Buster
Local time
Today, 12:24
Joined
Jun 29, 2001
Messages
396
I checked my error log, and there's no errors in it. The SetAddress(Me) function just takes the address that's entered in the record and puts it in another table. That function works, because I have it on the cmdSave_Click event for several other forms. Actually, the whole event is basically the same for the other forms and they work the way they should. That's what's got me stumped.
 

Users who are viewing this thread

Top Bottom