Re: Struggling with current record
From: Van T. Dinh (VanThien.Dinh_at_discussions.microsoft.com)
Date: 08/18/04
- Next message: Ethan_at_discussions.microsoft.com: "Re: Default Values for Query Parameters"
- Previous message: Van T. Dinh: "Re: Substituting my own MsgBox for the standard delete confirm MsgBox"
- In reply to: Laurel: "Re: Struggling with current record"
- Next in thread: Laurel: "Re: Struggling with current record"
- Reply: Laurel: "Re: Struggling with current record"
- Reply: Laurel: "Re: Struggling with current record"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 23:43:54 +1000
See comments in-line.
--
HTH
Van T. Dinh
MVP (Access)
"Laurel" <FakeMail@Hotmail.com> wrote in message
news:ujHpzNFhEHA.3964@TK2MSFTNGP12.phx.gbl...
>
> Yes, it hit me in the night that I'd put that OR in erroneously, but that
> was a very late change. Most of the time the code I was using was the
> "not(.eof and .bof) that was commented out below it.
>
Not (.EOF AND .BOF) is equivalent to
Not .EOF OR Not .BOF (by the Distributive Law)
This is NOT equivalent to what I posted.
> Here is a cleaner statement, I think, of one aspect of the problem.
>
> Overview. I want to 1) get a good recordcount of the rows visible in the
> form and 2)make sure I have a current record , so that I can execute
> subsequent scripts without error. To that end, I want to execute the
> .movelast .movefirst. I get an error if I attempt .movelast .movefirst
when
> the form has no rows, so I was advised to use .eof and .bof to test for no
> rows before trying to get the good recordcount. My problem is that EOF and
> BOF are both true (sometimes) even when there is a row in the form. One
> reproducible instance is when I create the first new row. I can clear up
> these problems if I click on the empty newrow that is automatically
> generated and then cick back on the row I just created, but I can't expect
> my users to do that (although they have, indeed, learned to do that....)
>
> Insert first row into empty form. Choose from a dropdown for a column with
a
> mouse. Click button that executes script.
>
> EOF BOF Me.CurrentRecord lrstMe.RecordCount
>
> TRUE TRUE 1 0
>
> TRUE TRUE 1 0
>
> TRUE TRUE 1 0
>
That's is entirely reasonable. The New Record is still in the Form's
buffer. The CurrentRecord is simply an ordinal number but the number of
Records in the Form's Recordset is still zero since (I think) the New Record
is not added to the Recordset until you save the Record. Hence, you get
True, True, 1, 0.
>
>
> If (.EOF And .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
>
> End With
>
> Dim li_debug As Integer
>
> li_debug = lrstMe.RecordCount
>
> If (Me.CurrentRecord = 0) Or (lrstMe.RecordCount = 0) Then
>
> MsgBox ("No current record" & vbCrLf & "Copy will not be done.")
>
> Exit Sub
>
> End If
>
I normally use only (example only):
Set rs = Me.RecordsetClone
If rs.RecordCount = 0 then
'Empty Recordset
Else
rs.MoveLast
rs.MoveFirst
Debug.Print "True Count = " & rs.RecordCount
End If
- Next message: Ethan_at_discussions.microsoft.com: "Re: Default Values for Query Parameters"
- Previous message: Van T. Dinh: "Re: Substituting my own MsgBox for the standard delete confirm MsgBox"
- In reply to: Laurel: "Re: Struggling with current record"
- Next in thread: Laurel: "Re: Struggling with current record"
- Reply: Laurel: "Re: Struggling with current record"
- Reply: Laurel: "Re: Struggling with current record"
- Messages sorted by: [ date ] [ thread ]