Form Save

Z

Zanstemic

I have a command button with a macro that opens a form and than does a
GoToRecord New. It has 4 fields

1) Auto Number (Primary Key and auto increments in system)
2) Date (defaults to now() )
3) Increment number (defaults to the number of records for that day)
4) Case Number (defaults to the combination of Date and Increment Number)

It's all working fine, except I can't figure out how to get the record to
auto save. I've tried a number of Docmd.Save or Requiry or macro saves, etc.

It seems that until I actually type something in the form, the Primary Key
which is an auto number for the record does not get created. Once I type in
any field, the Auto Number is created and funtions normally.

Any suggestions are appreciated.
 
J

Jeanette Cunningham

Yes, that is how Access works, the autonumber primary key is not created
until you begin entering data.
Normally, after you enter data for a new record, the data is automatically
saved when you go to a new record.
You wouldn't need to make any macro the save the record, unless you have a
close button on the form.
I'm not sure I've understood your question.
Do you have a problem with saving?

Jeanette Cunningham
 
Z

Zanstemic

The problem I'm having is that the field that is determined off the Date and
Increment Number is a required field with no duplicates

What happens is that the form opens fine and the calculations are correct in
the form but has not yet been saved to the table. If someone else opens the
form on another machine, they get the same calculation. When they go to save
the form they get an error. I'm trying to get the calculation done and saved
in the table as instantly as possible with the error checking done to make
sure the entry is saved to the table before an operator starts typing.
 
J

Jeanette Cunningham

It sounds as though you have a Primary Key that is a combination of the
current date and the next number in a sequence.
You calculate the new value for this Primary Key in the Before Update event
of the form. This is just before the record is written to disk.
If another person has the same form open, they also calculate the value in
the Before Update event, (they will get a different number when the function
gets the next number from the custom number table), normally this works fine
without any problems.

Jeanette Cunningham
 
Z

Zanstemic

This was very helpful.

Currently the calculations are done in the fields as default values. I'll
work on moving the calculation to the Before Update event.
 

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