G
Guest
I believe that was my fault because of a typo.
It should be:
=DMax("[Work_Order_Number]","2006 Work Orders")+1
It should be:
=DMax("[Work_Order_Number]","2006 Work Orders")+1
Ridnaway said:I think my 1st reply to this got lost somehow so I'll try again
Thank you for your thoughts. I changed the form to a data entry form and
typed the following expression into the Defaul Value line of the
Work_Order_Number field......=Max("[Work_Order_Number]","2006 Work
Orders")+1. But when I tried to exit I got the following error
message......"The expression you entered has a function containing the wrong
number of arguments." What was my error this time?
--
Ridnaway
BruceM said:I can get a bit testy at times. It doesn't help anything.
As Klatuu observed, get it working first. Multi-user can happen later. I
expect you are going to test it first for a while, so multi-user
environments aren't the first concern.
Ridnaway said:I apologize if it seems that I paid no attention to your previous posting.
In fact I did follow your link and tried to apply it. I would have even
paid
the $1 donation if I could've remembered my PayPal user/password. The
problem was that I became confused by the code
language/strings/expressions
and was unable to make sense of how to apply it to my specific table names
and field names. Certainly, in our multiple user environment getting a
duplicate numbering error will occur sooner or later and it will be good
to
have the knowledge to overcome that. For now, being an inexperienced user
I
guess I'll just have to muddle through this all until I can discuss it in
terms the experts are familiar with.
Have a good day Sir
--
Ridnaway
:
I expect you will pay no more attention to this than to my previous
posting,
but if you have a multi-user environment you will need to take steps to
guard against errors if two users enter a record at the same time.
Thanks! That sounds like just what I want it to do. I'm confused
about
which values to enter into the field properties though. I'm kind of
new
at
this and not entirely familiar with codes or syntax or expressions and
the
like. I've changed the field in the database from Autonumber to a text
field. Can I assume that in order to have the Work_Order_Number field
autopopulate that I should put an expression in the "default value"
property?
And if so would the expression then be =DMax[("table name","field
name")]+1
? (the table name is "2006 Work Orders" and the field name is
"Work
Order Number"
--
Ridnaway
:
If the Data Entry property of the form is set to Yes in design view,
then
it
is a data entry form. Data entry forms are for entering new data.
They
always start off blank, but without acctually creating a record.
If you form opens up with the first record in the recordset showing,
then
it
is not a data entry form. If this is the case and your control for
the
autonumber field is bound to the autonumber field, then when you
create a
new
record, the number should show up.
I am a little lost on a solution because I never use autonumbers as
data.
IMHO, users should never see them. They are intended to be used for
establishing key values for table relationships. One thing to be
aware
of is
that you will experience gaps in the numbering sequence. If a user
begins to
create a record, the cancels it, the number assigned is not reused.
Here is a method I use if I need a sequentially numbered field. It is
flexible enought it can be used even within a field that has other
repeating
values. For example, in once case, a user wanted a unique number that
was
Year, Month, and an incrementing number as in 2006040001, 2006040002,
2006050001, etc
But for example purposes, I will show you the basic way to do this.
Use
the
form's current event:
If Me.NewRecord then
Me.txtOrderNumber = Max("[OrderNumber]", "tblOrderHeader") + 1
End If
This emulates auto numbering, but leaves no gaps unless you delete a
record.
What happens is when you add a new record to your table, it looks for
the
highest value in the field you identify and adds 1 to it and puts it
in
the
text box for the order number.
:
It is a form. I'm not sure how to identify it as a data entry
form...didn't
know there was a difference. However, even if I begin entering data
in
the
next field it will not populate the autonumber. Thanks for your
help.
Any
other thoughts?
--
Ridnaway
:
If your form is defined as a Data Entry form, then it is for
adding
new
records and comes up will all controls empty. That is because a
record is
not actually created until you start entering data.
:
I am using a form to populate my database of work orders. I
have a
text box
on the form named "Work Order Number" and I want it to
automatically place
the next sequential number into this field upon opening the
form.
The field
is my table is named Work_Order_Number and is set at autonumber
but
it isn't
placing the number onto the form when opened. What have I not
done?