Displaying the RecordCount

  • Thread starter Thread starter Rob W
  • Start date Start date
R

Rob W

Greetings,

I have a form where I removed the navigation bar and have a label to print
the record number using :-

Me.lblRecordNumber.Caption = "Award Record number: " & [CurrentRecord]

It's printing unexpected results though, is this the correct variable to use
(Access 2007) ?
Im assuming CurrentRecord starts at 1.

Cheers
Rob
 
What's unexpected?

New Records will not work with that. Try this:

Me.lblRecordNumber.Caption = IIf([NewRecord], "New Record", "Award Record
number: " & [CurrentRecord]
 
Thanks for the reply,

I had 3 rows and upon navigating back and forth, the record number stayed
the same etc.., but thats probably alot to do with all the code behind it
too ...

Private Sub cmdNext_Click()

With Recordset
If .AbsolutePosition = .RecordCount - 1 Then
DoCmd.GoToRecord , , acNewRec

Me.lblAwardStudentCount.Caption = ""

Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

Else
'If Not IsNull(Me.txtAwardId) Then
StrAward = Me.txtAwardId
SAwards = DCount("[StudentID]", "tblStudent", "[AwardId] = """ &
StrAward & """")

Me.lblAwardStudentCount.Caption = ""
Me.lblAwardStudentCount.Caption = "Total students enrolled on
Award: " & SAwards


Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

DoCmd.RunCommand acCmdRecordsGoToNext
'End If

End If

End With

End Sub

Private Sub cmdPrevious_Click()

If [CurrentRecord] > 1 Then

If Not IsNull(Me.txtAwardId) Then
StrAward = Me.txtAwardId
SAwards = DCount("[StudentID]", "tblStudent", "[AwardId] = """ &
StrAward & """")

Me.lblAwardStudentCount.Caption = ""
Me.lblAwardStudentCount.Caption = "Total students enrolled on Award:
" & SAwards

Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

CAwards = DCount("[AwardId]", "tblAward")

Me.lblAwardCount.Caption = ""
Me.lblAwardCount.Caption = "Total number of Awards in the system is
: " & CAwards

End If

DoCmd.RunCommand acCmdRecordsGoToPrevious
End If

End Sub



Arvin Meyer said:
What's unexpected?

New Records will not work with that. Try this:

Me.lblRecordNumber.Caption = IIf([NewRecord], "New Record", "Award Record
number: " & [CurrentRecord]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Rob W said:
Greetings,

I have a form where I removed the navigation bar and have a label to
print the record number using :-

Me.lblRecordNumber.Caption = "Award Record number: " & [CurrentRecord]

It's printing unexpected results though, is this the correct variable to
use (Access 2007) ?
Im assuming CurrentRecord starts at 1.

Cheers
Rob
 
Just use this as the controlsource of a textbox:

=IIf([NewRecord],"New Record","Award Record number: " & [CurrentRecord])


--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Rob W said:
Thanks for the reply,

I had 3 rows and upon navigating back and forth, the record number stayed
the same etc.., but thats probably alot to do with all the code behind it
too ...

Private Sub cmdNext_Click()

With Recordset
If .AbsolutePosition = .RecordCount - 1 Then
DoCmd.GoToRecord , , acNewRec

Me.lblAwardStudentCount.Caption = ""

Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

Else
'If Not IsNull(Me.txtAwardId) Then
StrAward = Me.txtAwardId
SAwards = DCount("[StudentID]", "tblStudent", "[AwardId] = """
& StrAward & """")

Me.lblAwardStudentCount.Caption = ""
Me.lblAwardStudentCount.Caption = "Total students enrolled on
Award: " & SAwards


Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

DoCmd.RunCommand acCmdRecordsGoToNext
'End If

End If

End With

End Sub

Private Sub cmdPrevious_Click()

If [CurrentRecord] > 1 Then

If Not IsNull(Me.txtAwardId) Then
StrAward = Me.txtAwardId
SAwards = DCount("[StudentID]", "tblStudent", "[AwardId] = """ &
StrAward & """")

Me.lblAwardStudentCount.Caption = ""
Me.lblAwardStudentCount.Caption = "Total students enrolled on
Award: " & SAwards

Me.lblRecordNumber.Caption = ""
Me.lblRecordNumber.Caption = "Award Record number: " &
[CurrentRecord]

CAwards = DCount("[AwardId]", "tblAward")

Me.lblAwardCount.Caption = ""
Me.lblAwardCount.Caption = "Total number of Awards in the system is
: " & CAwards

End If

DoCmd.RunCommand acCmdRecordsGoToPrevious
End If

End Sub



Arvin Meyer said:
What's unexpected?

New Records will not work with that. Try this:

Me.lblRecordNumber.Caption = IIf([NewRecord], "New Record", "Award Record
number: " & [CurrentRecord]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Rob W said:
Greetings,

I have a form where I removed the navigation bar and have a label to
print the record number using :-

Me.lblRecordNumber.Caption = "Award Record number: " & [CurrentRecord]

It's printing unexpected results though, is this the correct variable to
use (Access 2007) ?
Im assuming CurrentRecord starts at 1.

Cheers
Rob
 

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

Back
Top