Record Counter Problem

G

Guest

I have hit problem on my current Access project and wondered if anyone could
help.

I am trying to implement the code below to create a customised record
counter (see http://databasedev.co.uk/navigation-record-count.html)

I have got it all to work fine - however, where I am implementing it on a
subform, and that subform holds no records I get an error with the .MoveLast
command. Is there any way I can make the .Movelast conditional (or somehow
avoid the error message).
 
G

Guest

I'm not sure where to put that code.

I have this at the moment:

Private Sub Next_LA_Click()
On Error GoTo Err_Next_LA_Click



DoCmd.GoToRecord , , acNext
Me![Progress (Measure Selecter)].Form.Combo10.Requery

Exit_Next_LA_Click:
Exit Sub

Err_Next_LA_Click:
MsgBox Err.Description
Resume Exit_Next_LA_Click

End Sub

where do I insert the bit of code you suggested?
 
G

Guest

actually, im not sure if thats the right bit of code ive just given you (i
don't really understand code). this may be it:

Private Sub Form_Current()

Dim lngCount As Long

Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount

End If
End With

Me.txtRecordNo = "AP Report " & Me.CurrentRecord & " of " & lngCount

End Sub

Burt said:
I'm not sure where to put that code.

I have this at the moment:

Private Sub Next_LA_Click()
On Error GoTo Err_Next_LA_Click



DoCmd.GoToRecord , , acNext
Me![Progress (Measure Selecter)].Form.Combo10.Requery

Exit_Next_LA_Click:
Exit Sub

Err_Next_LA_Click:
MsgBox Err.Description
Resume Exit_Next_LA_Click

End Sub

where do I insert the bit of code you suggested?

Klatuu said:
If MyRecordset.RecordCount > 0 Then
.MyRecordset.MoveLast
End If
 
G

Guest

no worries, i think we have sorted it with this:

With rst
lngCount = .RecordCount
If lngCount > 0 Then
.MoveFirst
.MoveLast
lngCount = .RecordCount
End If
End With


Burt said:
actually, im not sure if thats the right bit of code ive just given you (i
don't really understand code). this may be it:

Private Sub Form_Current()

Dim lngCount As Long

Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount

End If
End With

Me.txtRecordNo = "AP Report " & Me.CurrentRecord & " of " & lngCount

End Sub

Burt said:
I'm not sure where to put that code.

I have this at the moment:

Private Sub Next_LA_Click()
On Error GoTo Err_Next_LA_Click



DoCmd.GoToRecord , , acNext
Me![Progress (Measure Selecter)].Form.Combo10.Requery

Exit_Next_LA_Click:
Exit Sub

Err_Next_LA_Click:
MsgBox Err.Description
Resume Exit_Next_LA_Click

End Sub

where do I insert the bit of code you suggested?

Klatuu said:
If MyRecordset.RecordCount > 0 Then
.MyRecordset.MoveLast
End If
--
Dave Hargis, Microsoft Access MVP


:

I have hit problem on my current Access project and wondered if anyone could
help.

I am trying to implement the code below to create a customised record
counter (see http://databasedev.co.uk/navigation-record-count.html)

I have got it all to work fine - however, where I am implementing it on a
subform, and that subform holds no records I get an error with the .MoveLast
command. Is there any way I can make the .Movelast conditional (or somehow
avoid the error message).
 

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