Access get frozen

odrap

Registered User.
Local time
Today, 11:27
Joined
Dec 16, 2008
Messages
156
i have a dataentry form for managing persons from which i by products.
The form has as recordset : "tblLeveranciers". I can navigate from the first record in this table to the last and vice versa, and make changes to the data , save this changes and undo changes. Even when i click the button to add a new record, i get a form ready to enter new data, but when i try to save this data or undo the imput by clicking on the button "Save" or button "Undo", the form gets frozen and i'm oblige to get out of access via a unconventional manner. The strange thing about this story is that i have pratically the same form with the same code to manage clients, and there everything i going very well. There's no difference in the code of both forms to add a new record, undo the changes or save the new record! For this reason i checked the table as well as the qry's i use in the form, but i can't see any thing that can be the reason for this behavior. i use a qry to filter the form on opening, so that the same form can be used for current as welle as for ex delivery persons. I checked the result of this queries, and also that was OK. Beneath the code linked to the button "Save'" and the code linked to the button "undo"

Private Sub CmdOpslaan_Click()
On Error GoTo Error_Handler

If Me.Dirty Then
Me.Dirty = False
Me!Bookmark = Bladwijzer
End If

If Me.OpenArgs = "Current" Then
Me!cboZoekViaLevNr.Visible = True
Me!cboZoekViaExLevnr.Visible = False
Me!cboZoekViaLevNaam.Visible = True
Me!cboZoekViaExLevNaam.Visible = False
Me!CmdNieuw.Enabled = True
Me!CmdWijzigen.Enabled = True
ElseIf Me.OpenArgs = "Ex" Then
Me.CmdNieuw.Enabled = False
Me!cboZoekViaLevNr.Visible = False
Me!cboZoekViaExLevnr.Visible = True
Me!cboZoekViaLevNaam.Visible = False
Me!cboZoekViaExLevNaam.Visible = True
Me!lblExLev.ForeColor = 0
End If

Afsluiten:
On Error GoTo 0
Exit Sub
Error_Handler:
Call HandleError(Err.Number, Err.Description, "CmdOpslaan_Click", "frmLeveranciers")
Resume Afsluiten
End Sub

Private Sub CmdCancel_Click()
On Error GoTo Error_Handler

Application.Echo False


If Me.Dirty Then
DoCmd.RunCommand acCmdUndo
End If

If Me.NewRecord Then
Me.Bookmark = Bladwijzer
Me!CmdWijzigen.Enabled = True
Me!CmdSluiten.Enabled = True
End If


Me!cboZoekViaLevNr.Locked = False 'nodig anders na cmdnieuw en cmdcancel gelocked
Me!cboZoekViaLevNaam.Locked = False ' idem
Me!lblExLev.ForeColor = 0


If Me.OpenArgs = "Current" Then
Me!cboZoekViaLevNr.Visible = True
Me!cboZoekViaExLevnr.Visible = False
Me!cboZoekViaLevNaam.Visible = True
Me!cboZoekViaExLevNaam.Visible = False
If Me!CmdNieuw.Enabled = False Then
Me!Cmd!Nieuw.Enabled = True
End If

ElseIf Me.OpenArgs = "Ex" Then
Me!CmdNieuw.Enabled = False
Me!cboZoekViaLevNr.Visible = False
Me!cboZoekViaExLevnr.Visible = True
Me!cboZoekViaLevNaam.Visible = False
Me!cboZoekViaExLevNaam.Visible = True
End If

Application.Echo True
Afsluiten:
On Error GoTo 0
Exit Sub
Error_Handler:
Call HandleError(Err.Number, Err.Description, "CmdCancel_Click", "frmLeveranciers")
Resume Afsluiten

End Sub
 
When your program freezes, type control-break. The IDE shows the command to be executed. You need to inspect your code. Perhaps it's an endless loop?

Remove the line: Application.Echo True

It prevents Access from refreshing the screen. Since this is not Excel, you don't need it.

Enjoy!
 
Thank you for your advice.
Meanwhile i found the mistake , see code snippet beneath. In the Sub CmdCancel_click the name CmdNieuw was wrongly spelled

If Me!CmdNieuw.Enabled = False Then
Me!Cmd!Nieuw.Enabled = True
 
What caused the apparant freezing of the app whas the line

On Error GoTo 0
 
What caused the apparant freezing of the app whas the line

On Error GoTo 0

Really? I thought that was just a way of returning error handling to the control of Access (as opposed to handling it in your code).
 
On Error GoTo 0 disables error handling in the current procedure. It doesn't specify line 0 as the start of the error-handling code, even if the procedure contains a line numbered 0. Without an On Error GoTo 0 statement, an error handler is automatically disabled when a procedure is exited.

Therefore because you mispelled your control name and was detected by Access by setting the error trap to ignore it the False statement was never reached so it ended up in a perpetual loop.

David
 
Re: Access get frozen

When your program freezes, type control-break. The IDE shows the command to be executed. You need to inspect your code. Perhaps it's an endless loop?
You would have found it by pressing control-break (as i suggested) and stepping through the code using F8

Enjoy!
 
tapping control break doesn't solve the problem !
 
... and stepping through the code using F8?

Control-Break doesn't solve your problem, it just brings you to the code running.
 

Users who are viewing this thread

Back
Top Bottom