Record Number

E

Eli

I am trying to put a control in form that will show the
record number currently on. I was not able to find any
function that just simply displays the record number, not
the ID. Is there anybody there that know how to
accomplish that?

Thanks,
 
G

Graeme Richardson

Hi, place this code behind the form:

Private Function getRecordNumber() As Long
Dim rst As DAO.Recordset
Dim lngReturn As Long

Set rst = Me.RecordsetClone

If Me.NewRecord Then
rst.MoveLast
lngReturn = rst.AbsolutePosition + 2
Else
rst.Bookmark = Me.Bookmark
lngReturn = rst.AbsolutePosition + 1
End If

getRecordNumber = lngReturn
End Function

Create a text control on the form and set its ControlSource to
"=getRecordNumber()" (without quotes, of course).

Hope this helps, Graeme.
 
V

Van T. Dinh

May be easier to place a Calculated Control (TextBox) and set the
ControlSource to:

= CurrentRecord

(including the equal sign)?
 
A

albertsong

I have a form that opens in Add mode for users to enter more records. When
the user is finished entering one or more records and before they close the
form, I would like them to be able to push a button to view a report with
just the records they have entered while the form is still open.

Is there a way to use the CurrentRecord to do this?
 
S

StCyrM

Good afternoon

You can use the following code to perform the required action. Just make sure
you save the record first, ie. DoCmd.RunCommand acCmdSaveRecord

Private Sub RecordID_Click()

DoCmd.OpenReport "rptDetails", _
WhereCondition:="RecordID=" & Me.RecordID

End Sub


Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 
Top