not counts correctly

B

blendes

My code is supose to pop a message every tenth record. I found this code and
modifed it to make it work.

Private Sub Form_Load()
Me.txtCount = Me.Recordset.RecordCount

End Sub

Private Sub Form_AfterUpdate()
Dim lngCount As Long, lngStart As Long

lngCount = Me.Recordset.RecordCount
lngStart = Me.txtCount

If lngCount - lngStart >= 10 Then
' Reset txtCount
Me.txtCount = Me.Recordset.RecordCount
MsgBox "Please Do Cleanlines Test"
End If
End Sub

It pops up the message every record instead of every tenth record.
 
S

Stefan Hoffmann

hi,
My code is supose to pop a message every tenth record.
After reading it twice, this makes no sense for me. When do you want
exactly trigger this popup?

Try this:

Option Compare Database
Option Explicit

Private m_Count As Long

Private Sub Form_Load()

m_Count = 0

End Sub

Private Sub Form_AfterUpdate()

m_Count = m_Count + 1
If m_Count Mod 10 = 0 Then
MsgBox "Please Do Cleanlines Test"
End If

End Sub


mfG
--> stefan <--
 
D

Dale Fye

I think you want to use the CurrentRecord property, not RecordCount.

Me.CurrentRecord

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
B

blendes

thanks for the help.
So Me.txtCount = Me.Recordset.RecordCount
would become Me.txtCount = Me.Recordset.CurrentRecord
or did you mean it some where else.
 
D

Dale Fye

Actually, I think you can just use:

me.txtCount = me.CurrentRecord

I think, for what you are doing you will need to do this in each of the
instances where you are currently using the RecordCount property.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
T

Tom van Stiphout

On Tue, 9 Dec 2008 05:56:25 -0800, blendes

Did you set a breakpoint and find out what the value of lngCount is?
My guess is it's not what you expected.

with me.recordsetclone
.MoveLast
lngCount = .RecordCount
end with

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top