Form's BOF?

G

G Lam

Hi, I am using Access 2000 and I have a data input form; in the form's
default view set to continuous forms. The form's record source is a table.
In one of the fields' afterupdate event, how can I test (with VBA codes) if
the current record is the first record of this session of data entry in this
form?
Thank you in advance.
Gary
 
G

G Lam

Albert,
I added a field, LineNbr, to my table and the input form and wrote the
function. I then add a text box with the field's control source
=rpos([LineNbr]). But I got #Name? in that field.
Any idea?
Thank you for your help.
Gary
 
G

G Lam

Albert,
Thanks a lot. I figured it out. Your function worked perfectly.
Gary
G Lam said:
Albert,
I added a field, LineNbr, to my table and the input form and wrote the
function. I then add a text box with the field's control source
=rpos([LineNbr]). But I got #Name? in that field.
Any idea?
Thank you for your help.
Gary
Albert D. Kallal said:
You can use something like:

Function Rpos(vId As Variant) As Long

Rpos = 0
If IsNull(vId) = False Then
Me.RecordsetClone.FindFirst "id = " & vId
If Me.RecordsetClone.NoMatch = False Then
Rpos = Me.RecordsetClone.AbsolutePosition + 1
End If
End If

End Function

In fact, you can put the above code in a continues form, and place a text
box with the following expression:

=rpos([id])

The abovge will then "number" the reocrds start at one. the above examples
assume that you have a key id of "id"

Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn
 

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