Hiding "(AutoNumber)" until it is assigned.

N

nick

Hi Group.

I have a form on which I display various controls, including a read-only
text box which is to display the value of an autonumber field. When I
initially open the form up and before I start any data entry, the text box
that is display the autonumber simply says (AutoNumber). Once I begin
data-entry it updates to show the actual number, which is great.

Is there any way to stop it from displaying this "(AutoNumber)" placeholder
(for want of a better word) and leaving the box blank until I actually start
data-entry?

Thank you,

nick
 
J

John Vinson

Is there any way to stop it from displaying this "(AutoNumber)" placeholder
(for want of a better word) and leaving the box blank until I actually start
data-entry?

Since I never expose autonumbers to user view in any case - along with
many other Access developers - the issue doesn't come up.

Autonumbers are not designed for human consumption; they'll always
have gaps in the sequence and can become random. And if you don't
expose the autonumber value, you won't be exposing the <Autonumber>
either!
 
N

nick

John Vinson said:
Since I never expose autonumbers to user view in any case - along with
many other Access developers - the issue doesn't come up.

Autonumbers are not designed for human consumption; they'll always
have gaps in the sequence and can become random. And if you don't
expose the autonumber value, you won't be exposing the <Autonumber>
either!

Thanks John.

My problem is that I currently have to generate a new PO number (this is PO
form) automatically. The autonumber field is bloody awful because, as you
say... it easily gets it's knickers in a twist... and the PO numbers have
big gaps in if someone decides that they don't want to save this record
after all.

Trouble is, I'm generally a web developer and usually work with ASP and SQL
Server. We've been forced to do a project within MS Access itself and I'm
really struggling! :(

Any general suggestion as to how to supplement the evil autonumber with
something that'll do the job mentioned above? Also - and this is making me
tear my hair out - how do I stop Access from committing a record to a table
until I'm ready for it to? i.e. when I press a 'save' button?

Thanks ever s'much.

nick
 
J

John Vinson

Any general suggestion as to how to supplement the evil autonumber with
something that'll do the job mentioned above?

There's lots of examples on the web - do a Google Groups search for
"Custom Counter". VERY short example: in the Form's BeforeInsert event
put code like

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtPONumber = NZ(DMax("[PONumber]", "[PurchaseOrders]")) + 1
End Sub

The real code would need error trapping, etc. but that should give you
a start. It uses DMax to find the largest existing PO number; NZ to
return zero if there ARE no existing PO numbers; and adds 1, and then
sticks the result into the textbox txtPONumber (which is bound to the
PO Number field).
Also - and this is making me
tear my hair out - how do I stop Access from committing a record to a table
until I'm ready for it to? i.e. when I press a 'save' button?

This takes a bit of VBA too, and can be all but impossible if you have
subforms, since Access saves the record on the mainform the instant
you setfocus to a subform. Is this REALLY essential? Why?
 

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