Syncronize Record Number with Field

D

Doug_C

Hello,

On my form, I have a field for the user to input the current record number.
The reason for this is so on the report it will show what record number that
record is so if they want to view it on the form, rather than doing an "Edit"
"Find" they type the number in the record selctor box at the bottom of the
form.

My question is this:

Is there a way to make the record number field automatically fill in with
the current record number? Does something have to syncronize together or
would there be some code to put in the add record button?

Thanks!!!
 
K

Klatuu

There is no such thing as a record number. Any sorting or filtering will
affect the record number display on a form. It is only a relative
representation. Records are not stored in any predictable order in a Jet
database.
If you have an autonumber field in your table, or some other unique key
vaule, you should use that.
 
D

Doug_C

So basically, I should just stick with having the users type in the record
number manually that shows on the display. I have an autonumber field on the
main form. How would I get that number to show on the form?
 
K

Klatuu

I don't think you quite understand, Doug. What I am saying is that the
number on the form is not the record number of the currently displayed
record. It is only the relative position of the current recordset. If you
change the filtering or the order, or add or delete records, the number is no
longer useful. It was, IMHO, a mistake for Access to even include this. You
can never depend on getting the same record twice. But, if you must, you can
put this in the Current event of your form:
Me.Text2 = Me.Recordset.AbsolutePosition + 1
Where Text2 is where you want to display it.
Anyway, when it doesn't work as expected, you will understand.
 
D

Doug_C

Hi Klaatu,

I do understand what you are saying. In fact, What you said is what I tried
to explain to management. To go even further, I also explain the repercussion
in the event of what you said comes true. Unfortunately, they are the powers
that be so if they want this I am obligated to try and come up something no
what how much I disagree with it. I go through this from time to time so I'm
use to doing things blowing up later due to a bad call. Thank you though for
your concern and looking out for me. I will plug in your code to satisfy the
situation and again, thank you for your help it is most appreciated!!
 
K

Klatuu

What a strange situation. Do you mean to say that sometimes you have to do
things you know are bad ideas to meet Management's unreasonable demands? I
can't imagine such a situation :) Let me guess - when it blows up, it is
your fault, right.
 
D

Doug_C

Not all the time. Although they would like to it was something I did wrong.
Unfortunately I can't come back and say "I told you so", but it would be
nice! :eek:)
 
Top