L
Laurel
I'm struggling with having "no current record." I see a row or rows in the
form in question (this happens to me in a variety of forms), but the code
associated with the form detects "no current record." I've asked this of
this forum before and various suggestions for testing are below. Just now I
inserted a row, the first row in an empty form, and edited one column and
clicked on a button that triggered the offending script. .EOF was TRUE and
..BOF was false - thus no current record. I did it again and both were TRUE.
Further Me.CurrentRecord = 1 and lrstMe.RecordCount = 0. (How can
Me.CurrentRecord = 1 if .EOF is TRUE????) Most times when I do the same
thing, .EOF and .BOF are both false and the rest of the script executes as
expected. HELP!
I guess there are two issues - testing for no records in the recordset, and
testing for a current record... But that remains confusing.
I've gotten a lot of suggestions about how to test for whether there is a
current record. What I need is advice about how to ensure that there is a
current record when I execute a script when I can see a record in front of
me on the form.
Dim lrstMe As Recordset
Set lrstMe = Me.Recordset
With lrstMe
If (.EOF Or .BOF) Then
lngRecCount = 0 'No current record
Else
.MoveLast
lngRecCount = .RecordCount
.MoveFirst
End If
DoEvents 'Trying to get rid of occasional weird errors - feel like timing
problems
If (Me.CurrentRecord = 0) Or (lrstMe.RecordCount = 0) Then
MsgBox ("No current record" & vbCrLf & "Copy will not be done.")
Exit Sub
End If
OTHER SUGGESTIONS FOR TESTING FOR WH
'HERE'S ANOTHER APPROACH FROM THE NEWSGROUP
' You could try code like this:
' dim bkmk as variant
' with rst
' bkmk=.bookmark
' .movelast
' .movefirst
' .bookmark=bkmk NOTE THIS METHOD OF USING BOOKMARK
and another
'If Not (.EOF And .BOF) Then
' .MoveLast
' lngRecCount = .RecordCount
' .MoveFirst
' Else
' lngRecCount = 0
' End If
'End With
form in question (this happens to me in a variety of forms), but the code
associated with the form detects "no current record." I've asked this of
this forum before and various suggestions for testing are below. Just now I
inserted a row, the first row in an empty form, and edited one column and
clicked on a button that triggered the offending script. .EOF was TRUE and
..BOF was false - thus no current record. I did it again and both were TRUE.
Further Me.CurrentRecord = 1 and lrstMe.RecordCount = 0. (How can
Me.CurrentRecord = 1 if .EOF is TRUE????) Most times when I do the same
thing, .EOF and .BOF are both false and the rest of the script executes as
expected. HELP!
I guess there are two issues - testing for no records in the recordset, and
testing for a current record... But that remains confusing.
I've gotten a lot of suggestions about how to test for whether there is a
current record. What I need is advice about how to ensure that there is a
current record when I execute a script when I can see a record in front of
me on the form.
Dim lrstMe As Recordset
Set lrstMe = Me.Recordset
With lrstMe
If (.EOF Or .BOF) Then
lngRecCount = 0 'No current record
Else
.MoveLast
lngRecCount = .RecordCount
.MoveFirst
End If
DoEvents 'Trying to get rid of occasional weird errors - feel like timing
problems
If (Me.CurrentRecord = 0) Or (lrstMe.RecordCount = 0) Then
MsgBox ("No current record" & vbCrLf & "Copy will not be done.")
Exit Sub
End If
OTHER SUGGESTIONS FOR TESTING FOR WH
'HERE'S ANOTHER APPROACH FROM THE NEWSGROUP
' You could try code like this:
' dim bkmk as variant
' with rst
' bkmk=.bookmark
' .movelast
' .movefirst
' .bookmark=bkmk NOTE THIS METHOD OF USING BOOKMARK
and another
'If Not (.EOF And .BOF) Then
' .MoveLast
' lngRecCount = .RecordCount
' .MoveFirst
' Else
' lngRecCount = 0
' End If
'End With