Re: How do i...
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Mon, 17 Mar 2008 16:37:05 -0600
What I posted before does exactly what you asked, but maybe
you asked the wrong question?
I think you might be confusing two different things. The
record number in the nav buttons is only useful for the
form's current set of records. Different criteria, sort
order and other thing will result in any specific record
having a different number each time you view the records.
If you want each record to retain its number regardless of
all those things, then you need to have a field in your
table and use code in the form's BeforeUpdate event to set
the number:
Me.numberfield = Nz(DMax("numberfield", "table"), 0) + 1
In case you did ask your original question correctly and to
answer your current question, a form that displays multiple
records can not use VBA code to display different values in
an unbound text box. Instead, you need to create a function
to calculate the record number and use the function in a
text box. This can be slow if the form is used to display a
lot of records, but it will do what you originally asked:
Public Function GetRecNum(pk As ???)
With Me.RecordsetClone
.FindFirst "primarykeyfield=" & pk
GetRecNum = .AbsoluteRecord + 1
End With
End Function
With that function, the text box's expression would be:
=GetRecNum(primarykeyfield)
--
Marsh
MVP [MS Access]
Pwyd wrote:
In what way is it insufficient?.
"Marshall Barton" wrote:
Pwyd wrote:
I'd like to put the record number shown in the record selector ON the form
itself, on top of the form. In fact, i'd like to leave the record selector
alone, and simply show the record number the user is looking at, on the form
itself, so it may print out.
You can set a text box's value to the form recordset's
AbsolutePosition property:
Sub Form_Current()
Me.textbox = Me.Recordset,AbsolutePosition +1
Note: that is insufficient on continuous and datasheet
forms.
- References:
- Re: How do i...
- From: Marshall Barton
- Re: How do i...
- Prev by Date: Re: Timer Count Down
- Next by Date: =<expr> function call - how to pass record?
- Previous by thread: Re: How do i...
- Next by thread: RE: How do i...
- Index(es):
Relevant Pages
|