Displaying the RecordCount

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
 
A

Arvin Meyer [MVP]

What's unexpected?

New Records will not work with that. Try this:

Me.lblRecordNumber.Caption = IIf([NewRecord], "New Record", "Award Record
number: " & [CurrentRecord]
 
R

Rob W

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
 
A

Arvin Meyer [MVP]

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
 
Top