Auto number a fom

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I made a form with 2 tabs. I would like an auto generated number be assigned
upon opening the form and choosing a tab. Currently it display "auto num.."
in the field until the first data area is used. Then it assignes a number.
My goal: each time a person opens the form it stores all entered data with
it's own specific entry number. Then at a later time I will create a search
option by this number.
Thanks
 
The AutoNum will give you a unique number.
Just go with that.

You do not want to assign a number until the user starts entering something.
If you assign the new number just because someone visited the new record
(whether they actually want to enter something or not), you are going to get
lots of blank records saved.
 
TRS said:
I made a form with 2 tabs. I would like an auto generated number be
assigned upon opening the form and choosing a tab. Currently it
display "auto num.." in the field until the first data area is used.
Then it assignes a number. My goal: each time a person opens the form
it stores all entered data with it's own specific entry number. Then
at a later time I will create a search option by this number.
Thanks

That's what a bound form should do and you already have an AutoNumber to provide
a unique number to each record so what's the problem?
 
If you want to create a search option you probably want a choice other than
the number. Searching by that number means you would need a way of knowing
in advance what the number is. If the number is to be seen by the users (an
invoice number or other sequential number that appears on reports, etc.)
then autonumber is not a good choice, as it will almost surely leave gaps in
the numbering sequence.
 
I don't like the "auto..." caption seen in the field by the customer until
they enter data. Is there any way to mask this? Thanks
 
To anyone who knows about Access, the "AutoNum" is meaningful info.

But, if you want to hide it, here's a couple of ways.
The examples assume the Autonumber field is named ClientID.

1. Change the Contorl Source, since the user will not enter a value anyway.
Set these properties:
Control Source =IIf([Form].[NewRecord], Null, [ClientID])
Format General Number
Name txtClientID
(Note that the name of the text box must be different from the name of the
field if it is bound to something else, such as the expression.)

2. Mask it with Conditional Formating.
Assuming Access 2000 or later, open the form in design view.
Select the text box.
Choose Conditional Formatting on the Format menu
Set Condition 1 to:
Expression ... [ClientID] Is Null
and choose the white text color.
 
If you need to find a single record you can use the combo box wizard. Open
the form in design view, click the Toolbox icon, make sure the magic wand is
highlighted, click the Combo Box icon, and draw a combo box on the form.
Choose the option to Find a record based on the selection (or something like
that). Follow the prompts, and you should have what you need. Write back
if it gives you any trouble.
Another option is to filter the records. For instance, in a Contacts
database you may wish to find everybody who lives in Anytown. One way to do
that is to right click the text box bound to that field and choose one of
the Filter options. Another way is to have a separate combo box, but don't
use the wizard. I won't go into detail since I don't know if this is what
you want, but in general terms once you set up the combo box Row Source to
include the City field (which isn't difficult), a single line of code may do
all that you need, something like:
DoCmd.ApplyFilter , "[City]=""" & ComboBoxName & """"
 
Back
Top