R
Rob
Hi all,
With help from Klatuu, I was able to refine some code that I have previously
written to remove a filter and move to a specific record. I then needed to check
the status of the record before allowing the move to the new record. I did this
using a function (see below). The problem I am now having is that the filter is
being removed, but I remain at the first record. I have confirmed that the
problem is in the CheckTaskMovement area as when I comment it out is works as
expected. Any help would be greatly appreciated,
TIA and Cheers
Rob
--------------------------------
txtGotoTaskID After Update
' If the task exists remove filter and move to the record
If Not IsNull(ELookup("[taskID]", Me.RecordSource, "[taskID] = " &
Me!txtGotoTaskID)) Then
If CheckTaskMovement Then
Me.FilterOn = False
Me.Filter = vbNullString
With Me.RecordsetClone
.FindFirst "[TaskID] = " & Me!txtGotoTaskID
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Else
Me!txtGotoTaskID.Value = Me![taskID]
End If
---------------------------------
Private Function CheckTaskMovement() As Boolean
On Error GoTo CheckTaskMovement_ErrorHandler
Dim bRetValue As Boolean
bRetValue = False
If Me.Dirty Then
Select Case MsgBox(strSave, vbQuestion + vbYesNoCancel, "Save Task?")
Case vbYes
Me.Dirty = False
bRetValue = True
Case vbNo
Me.Undo
bRetValue = True
Case vbCancel
bRetValue = False
End Select
Else
bRetValue = True
End If
CheckTaskMovement_ExitHandler:
CheckTaskMovement = bRetValue
Exit Function
CheckTaskMovement_ErrorHandler:
ErrMsg Me, "CheckTaskMovement", err
Resume CheckTaskMovement_ExitHandler
End Function
With help from Klatuu, I was able to refine some code that I have previously
written to remove a filter and move to a specific record. I then needed to check
the status of the record before allowing the move to the new record. I did this
using a function (see below). The problem I am now having is that the filter is
being removed, but I remain at the first record. I have confirmed that the
problem is in the CheckTaskMovement area as when I comment it out is works as
expected. Any help would be greatly appreciated,
TIA and Cheers
Rob
--------------------------------
txtGotoTaskID After Update
' If the task exists remove filter and move to the record
If Not IsNull(ELookup("[taskID]", Me.RecordSource, "[taskID] = " &
Me!txtGotoTaskID)) Then
If CheckTaskMovement Then
Me.FilterOn = False
Me.Filter = vbNullString
With Me.RecordsetClone
.FindFirst "[TaskID] = " & Me!txtGotoTaskID
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Else
Me!txtGotoTaskID.Value = Me![taskID]
End If
---------------------------------
Private Function CheckTaskMovement() As Boolean
On Error GoTo CheckTaskMovement_ErrorHandler
Dim bRetValue As Boolean
bRetValue = False
If Me.Dirty Then
Select Case MsgBox(strSave, vbQuestion + vbYesNoCancel, "Save Task?")
Case vbYes
Me.Dirty = False
bRetValue = True
Case vbNo
Me.Undo
bRetValue = True
Case vbCancel
bRetValue = False
End Select
Else
bRetValue = True
End If
CheckTaskMovement_ExitHandler:
CheckTaskMovement = bRetValue
Exit Function
CheckTaskMovement_ErrorHandler:
ErrMsg Me, "CheckTaskMovement", err
Resume CheckTaskMovement_ExitHandler
End Function