Hi,
I have behind butons code to "find" certain recordsets, the code is almost the same for find, findfirst, findnext, findlast. To make things easier to explain, I copy the 'findlast' code and describe (one of) the problem(s):
Private Sub btn_LastRec_Click()
'Purpose: Find the last matching recordset
'sFind can be string. number,or date expression
Const cstrProc As String = "btn_LastRec_Click"
On Error GoTo btn_LastRec_Click_Err
Dim rst As Recordset
Dim Oldbook as Integer
Set rst = Me.RecordsetClone
MsgBox rst.AbsolutePosition (1. MsgBox, this is added for examination purposes only)
rst.FindLast sFind
Me.Bookmark = rst.Bookmark
MsgBox rst.AbsolutePosition (2. MsgBox, this is added for examination purposes only)
'(3rd MsgBox - should fire when last match)
If OldBook = rst.AbsolutePosition Then
MsgBox "You are already on the last recordset matching the criteria '" & sFind & "'." & Space(12), vbInformation, gsApplName
GoTo btn_LastRec_Click_Exit
End If
OldBook = rst.AbsolutePosition
Set rst = Nothing
btn_LastRec_Click_Exit:
Exit Sub
btn_LastRec_Click_Err:
Call bss_ErrMsgStd(Me.Name & "." & cstrProc, Err.Number, Err.Description, True)
Resume btn_LastRec_Click_Exit
End Sub
Let's presume rst.Absoluteposition is 799 for this last matching record.
Now what happens, when I start e.g.from record 240:
If I fire the button, the last matching recordset is found (which is ok). The msgboxes describing the position indicate following positions:
1. MsgBox: 240
2. Msgbox: 798
Should that not be 799? 798 is a no match.
I press the button again and now
1. MsgBox: 798
2. MsgBox: 799
Acutally, expectation is that the third msgbox should show, but it does not. No visible change; the user would have the impression that nothing happended.
Now I press the button again with the result:
1. Msgbox: 799
2. MsgBox: 799
3. Msgbox shows.
Can somebody tell, what I am doing wrong? Thanks.
georgp
I have behind butons code to "find" certain recordsets, the code is almost the same for find, findfirst, findnext, findlast. To make things easier to explain, I copy the 'findlast' code and describe (one of) the problem(s):
Private Sub btn_LastRec_Click()
'Purpose: Find the last matching recordset
'sFind can be string. number,or date expression
Const cstrProc As String = "btn_LastRec_Click"
On Error GoTo btn_LastRec_Click_Err
Dim rst As Recordset
Dim Oldbook as Integer
Set rst = Me.RecordsetClone
MsgBox rst.AbsolutePosition (1. MsgBox, this is added for examination purposes only)
rst.FindLast sFind
Me.Bookmark = rst.Bookmark
MsgBox rst.AbsolutePosition (2. MsgBox, this is added for examination purposes only)
'(3rd MsgBox - should fire when last match)
If OldBook = rst.AbsolutePosition Then
MsgBox "You are already on the last recordset matching the criteria '" & sFind & "'." & Space(12), vbInformation, gsApplName
GoTo btn_LastRec_Click_Exit
End If
OldBook = rst.AbsolutePosition
Set rst = Nothing
btn_LastRec_Click_Exit:
Exit Sub
btn_LastRec_Click_Err:
Call bss_ErrMsgStd(Me.Name & "." & cstrProc, Err.Number, Err.Description, True)
Resume btn_LastRec_Click_Exit
End Sub
Let's presume rst.Absoluteposition is 799 for this last matching record.
Now what happens, when I start e.g.from record 240:
If I fire the button, the last matching recordset is found (which is ok). The msgboxes describing the position indicate following positions:
1. MsgBox: 240
2. Msgbox: 798
Should that not be 799? 798 is a no match.
I press the button again and now
1. MsgBox: 798
2. MsgBox: 799
Acutally, expectation is that the third msgbox should show, but it does not. No visible change; the user would have the impression that nothing happended.
Now I press the button again with the result:
1. Msgbox: 799
2. MsgBox: 799
3. Msgbox shows.
Can somebody tell, what I am doing wrong? Thanks.
georgp