G
Guest
I have isolated a strange problem having to do with a bookmark
I have a standard navigation routine that sets the command buttons on each
form. This was originally developed for MDB’s and worked fine. Since
converting to an ADP I am finding this strange problem. Aren’t they all?
The user clicks on an Undo button which performs a Me.Undo, foolowed by a
call to the standard navigation routine to enable/disable nav buttons. On
some forms in this ADP it works fine on other forms the UNDO is being
ignored/cancelled. Bet you thought that wasn’t possible? I sure did!
The line of code below is the culprit ! isolated by testing
( .Bookmark = ParentForm.Bookmark)
The routine is not generating an error it is just somehow cancelling the Undo
Any thoughts, ideas or clever discources? Thanks for your help!
RJ
Private Rst As ADODB.Recordset
Private RstAllowAdds As Boolean
Private CurrentNew As Boolean
Public Sub Set_Navigation_Buttons(ParentForm As Form, NavigationOption As
Long)
' This function enables and disables navigation buttons as
' necessary, depending on the current main form record
On Error Resume Next
If NavigationOption = 1 Then
'Form is Clean
ParentForm.FormSetfocus.SetFocus ' so we dont bump into
any focused buttons
ParentForm.cmdClose.Enabled = True
ParentForm.cmdWrite.Enabled = False
ParentForm.CmdUndo.Enabled = False
CurrentNew = ParentForm.NewRecord
RstAllowAdds = ParentForm.AllowAdditions
If CurrentNew Then
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
ParentForm.cmdPrev.Enabled = (Rst.RecordCount > 0)
Else
Set Rst = ParentForm.Recordset.Clone
With Rst
' Check Previous Record Ability
.Bookmark = ParentForm.Bookmark
.MovePrevious
ParentForm.cmdPrev.Enabled = Not .BOF
' Check Next Record Ability
.Bookmark = ParentForm.Bookmark
.MoveNext
ParentForm.cmdNext.Enabled = Not .EOF
'Check New Record Ability
ParentForm.cmdNew.Enabled = RstAllowAdds
.Close
End With
End If
Set_Toolbar_Enabled (True)
Else
'Form is Dirty so disable all but Write / Undo button
ParentForm.cmdWrite.Enabled = True
ParentForm.CmdUndo.Enabled = True
ParentForm.cmdClose.Enabled = False
ParentForm.cmdPrev.Enabled = False
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
Set_Toolbar_Enabled (False)
End If
End Sub
I have a standard navigation routine that sets the command buttons on each
form. This was originally developed for MDB’s and worked fine. Since
converting to an ADP I am finding this strange problem. Aren’t they all?
The user clicks on an Undo button which performs a Me.Undo, foolowed by a
call to the standard navigation routine to enable/disable nav buttons. On
some forms in this ADP it works fine on other forms the UNDO is being
ignored/cancelled. Bet you thought that wasn’t possible? I sure did!
The line of code below is the culprit ! isolated by testing
( .Bookmark = ParentForm.Bookmark)
The routine is not generating an error it is just somehow cancelling the Undo
Any thoughts, ideas or clever discources? Thanks for your help!
RJ
Private Rst As ADODB.Recordset
Private RstAllowAdds As Boolean
Private CurrentNew As Boolean
Public Sub Set_Navigation_Buttons(ParentForm As Form, NavigationOption As
Long)
' This function enables and disables navigation buttons as
' necessary, depending on the current main form record
On Error Resume Next
If NavigationOption = 1 Then
'Form is Clean
ParentForm.FormSetfocus.SetFocus ' so we dont bump into
any focused buttons
ParentForm.cmdClose.Enabled = True
ParentForm.cmdWrite.Enabled = False
ParentForm.CmdUndo.Enabled = False
CurrentNew = ParentForm.NewRecord
RstAllowAdds = ParentForm.AllowAdditions
If CurrentNew Then
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
ParentForm.cmdPrev.Enabled = (Rst.RecordCount > 0)
Else
Set Rst = ParentForm.Recordset.Clone
With Rst
' Check Previous Record Ability
.Bookmark = ParentForm.Bookmark
.MovePrevious
ParentForm.cmdPrev.Enabled = Not .BOF
' Check Next Record Ability
.Bookmark = ParentForm.Bookmark
.MoveNext
ParentForm.cmdNext.Enabled = Not .EOF
'Check New Record Ability
ParentForm.cmdNew.Enabled = RstAllowAdds
.Close
End With
End If
Set_Toolbar_Enabled (True)
Else
'Form is Dirty so disable all but Write / Undo button
ParentForm.cmdWrite.Enabled = True
ParentForm.CmdUndo.Enabled = True
ParentForm.cmdClose.Enabled = False
ParentForm.cmdPrev.Enabled = False
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
Set_Toolbar_Enabled (False)
End If
End Sub