Re: How do i...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
.



Relevant Pages

  • RE: Inserting Hyperlinks into table fields
    ... using VBA Code. ... Private Sub InsertRecBtn_Click ... "Text to display" is the text string to be displayed in the ... See http://www.QBuilt.com for all your database needs. ...
    (microsoft.public.access.modulesdaovba)
  • Re: I need help with a login form too
    ... We do not care about what sex you are. ... I was having trouble with cut, copy, and paste too but I am ... > Then unload me part was confusing me. ... >>> display an appropriate message. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Show common words in document?
    ... write up a little VBA code to go through the document and count the ... you may find this free download useful. ... Dian D. Chapman ... Is there a way to export or display the common words in a single word ...
    (microsoft.public.word.docmanagement)
  • Re: how/what dialog boxes can I display from VBA code
    ... MsgBox is modal, you can't add to it after it's displayed, and the code won't proceed until the user dismisses the message box. ... But that won't have the transparency or timed removal you have with the new message toast window that Outlook shows. ... There are 3rd party controls you can purchase that you can set transparency on and you can call and dismiss them based on a timer control, but that's not really appropriate for VBA code. ... Could you please suggest how/what dialog box that I can display from VBA code? ...
    (microsoft.public.outlook.program_vba)
  • Re: Print Directory to Excel
    ... runs a .exe file and at work our pc's are set up to not allow us to install ... saved, etc is displayed, I also wan to display the owner of the file/folder. ... They're both VBA code. ...
    (microsoft.public.excel.misc)