Form building

A

Annette

Hello I am new to access.
I Just built my first form and I am trying to figure out when I open the
form I want it to automaticly start on a new record?
 
A

Annette

Sorry Rick I am new to this can you please explain this a little better.
where is the forms open event. do I click on properties before or after I
open the form? Help!!!! Do I click in the first text box in my form and then
click properties?
 
R

Rick B

Open your form in design view.

Then click View/Properties from the menu.

In the EVENT tab double click on the ON OPEN line. It should change to
[Event Procedure].

Click the elipse button [...] to the right of the "event procedure" and it
should open up the code window.

You should see a line that says ...

Private Sub Form_Open(Cancel As Integer)

and a line that says

Ens Sub



In between those two lines, paste the statement I gave you earlier. The
ends result should be...

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord,,acNewRec
End Sub





Then close the code window.

Close the properties box.

Close and save your form.

When you reopen the form, it should go to a new record.
 
A

Albert D.Kallal

Just set the forms "data entry" property to yes, and the form will always
add new records....

This does of course prevent you from going back to old records, so I am not
100% sure if this is an ideal solution for you..
 
A

Annette

Thank you Rick.

This worked great. My other concern is I don't want it to duplicate any
order no. I want to be able to put a order no in and if it is already
excisting it should pop up with the information if not it should stay blank.
Is this where the primary key would come into play?


--
Thanks Annette


Rick B said:
Open your form in design view.

Then click View/Properties from the menu.

In the EVENT tab double click on the ON OPEN line. It should change to
[Event Procedure].

Click the elipse button [...] to the right of the "event procedure" and it
should open up the code window.

You should see a line that says ...

Private Sub Form_Open(Cancel As Integer)

and a line that says

Ens Sub



In between those two lines, paste the statement I gave you earlier. The
ends result should be...

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord,,acNewRec
End Sub





Then close the code window.

Close the properties box.

Close and save your form.

When you reopen the form, it should go to a new record.
 
L

Luke Dalessandro

Annette,

Open the table underlying the form in "design view". Select the "order
no" field. Then at the bottom, under the "General" tab, the last option
is "Indexed". Set this to "Yes (no duplicates)".

This will prevent people from entering duplicate order numbers. If you
have set order number as the primary key, it will automatically set the
"Indexed" property to "Yes (no duplicates)" for you.

If order number is set to the type "AutoNumber", it will automatically
get filled in by the system with the next available order number, which
is automatically unique.

Note that if you delete a record, thus deleting an "order id", the
AutoNumber will not go backwards to choose it again. so if I have orders
1-100, after deleting #50, the next entered order will be 101. If i
deleted #100 the next order would still be 101. AutoNumbers are not reused.

Luke
 
A

Annette

Thanks Luke I understand what you said, the questions I still can not solve
is when I put in a exsiting order no. I want it to pop up and this way my
employee can veiw pre exsiting orders. maybe I miss a step somewhere?
 
L

Luke Dalessandro

Annette,

Where is the order number coming from? Is the database generating it or
is it external?

If you want to search for orders based on order number, you can use the
built in find form that comes with access to do that... put your cursor
in the order number text box and click the binoculars or press [ctrl]-F.

It may be that I don't understand what you're trying to do, and being
more explicit in your description would help.

Luke
 

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