saving record (1 Viewer)

bluey

Registered User.
Local time
Today, 18:16
Joined
May 14, 2002
Messages
22
how do i save a record without using a button.
i know acces saves records but i get a write conflict if i dont save manually.
 

Travis

Registered User.
Local time
Today, 10:16
Joined
Dec 17, 1999
Messages
1,332
Lookup Docmd.RunCommand acCMDSaveRecord
 

bri822

Registered User.
Local time
Today, 18:16
Joined
May 23, 2002
Messages
31
If you are closing your form, another way to save is:

DoCmd.Close , , acSaveYes

Upon closing your form it saves the data you entered, therefore you don't need to have a button
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:16
Joined
Feb 19, 2002
Messages
43,451
Sorry bri822 but that doesn't save the current record, it saves the form.

The current record is saved automatically by Access between the BeforeUpdate and AfterUpdate events of the form. When you close a form that is "dirty", the BeforeUpdate and AfterUpdate events are run and that is what saves the record NOT the close method.

The command posted by Travis is the one to use, if you want the form to remain open.
 

bluey

Registered User.
Local time
Today, 18:16
Joined
May 14, 2002
Messages
22
No i dont want the form to remain open i would like it to save when it closes.
and if possable save the record NOT the form
please :)
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:16
Joined
Feb 19, 2002
Messages
43,451
Did you read my previous post? Access AUTOMATICALLY saves the current record when a form is closed.
 

bluey

Registered User.
Local time
Today, 18:16
Joined
May 14, 2002
Messages
22
yes i did read it and in this particular instance it needs to be saves using some other means.

if you read my first post you would have seen ?
I stated that i under stood it saved automatically but a conflict occurs unless my data is saves another way.

i dont want to save anotherway but if i cant find another way of saving the records automatically ile have no choice.

(probably wont though)
 
Last edited:

Carolyn

Registered User.
Local time
Today, 12:16
Joined
Jun 14, 2002
Messages
28
Hi Pat,

Thanks for the information I find your knowledge to be very valuable. Please tell me where do I put
Lookup Docmd.RunCommand acCMDSaveRecord?

Thank you for your time:)

Carolyn
 

ghudson

Registered User.
Local time
Today, 13:16
Joined
Jun 8, 2002
Messages
6,195
Carolyn,

Put the code

Docmd.RunCommand acCMDSaveRecord

in an event or assign it to a command button to save the record.

Here is an example of using the Docmd.RunCommand acCMDSaveRecord in the On Click event for a command button named bSave.

Private Sub bSave_Click()
DoCmd.RunCommand acCmdSaveRecord
End Sub

HTH
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:16
Joined
Feb 19, 2002
Messages
43,451
bluey,
If you have a write conflict, there is something wrong with the way your form is working. You need to fix that rather than trying to find an alternate way to save the current record. Is the form bound to a query or the table? Do you have some other form open at the same time bound to the same recordsource? A form with a subform bound to the same recordsource as the main form would conflict. A form that opens another form that uses the same recordsource as the first form would conflict.

Carolyn,
Your question is out of context so I don't know what you are trying to do. Travis was suggesting that bluey look in help for:
Docmd.RunCommand acCMDSaveRecord

This command is used whenever you want to save the record yourself in code. This is necessary if you have built a save button on a form or if you open a second form or report from the first one and the subsequent form/report needs info from the first form. If you haven't yet saved the current record, the subsequend form/report cannot "see" it.
 

Carolyn

Registered User.
Local time
Today, 12:16
Joined
Jun 14, 2002
Messages
28
Thank you ghudson and Pat I think I actually understand!:):)

Carolyn
 

bluey

Registered User.
Local time
Today, 18:16
Joined
May 14, 2002
Messages
22
humm quite possably:
it dosen't matter if you cant help ile probably figure it out aventually.

My input form is initially a query but it is also linked to a macro which is made up of a delete qry\ update date qry\2 append qrys.

Im telling you this stuff so hopefully you will be able to understand what ime trying to do or not.

The qry/form has date/dayno/dayname/rota name. which can have data typed in to it manually, to create the records desired
you press a button after all the data a is entered and a macro is run in this order

setwarnings
open qry Delete dates:
open qry Generate dates} run 7 times in order shown
open qry increase date qry} run 7 times
open qry generate dates
open qry create rota records: this is were all the data is put in to my main form.
Cose the input form is closed

The delete qry deletes things in a table called days of week which containd a date field and 5 dates.

The update field updates a table called rota control this contains
a date /day no/rota name there is only one set of records in this table at a time.
this is nesasarry so i can specify what i want updating and so i dont get everything updating at once.

Finally i have an append qry which puts all this data into days of the week. and another append qry which appends allthe data from all the tables in to my mane form

I get the problem when i try to change things in the input form
probably more than you wanted to know.....os im sorry .
but it is complicated.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:16
Joined
Feb 19, 2002
Messages
43,451
Let me summarize.

You have a bound form. This form has some unbound columns that are used for creating rows that you eventually want to view and edit from this form.

Possible solution.

Break the original form into two forms. The first is unbound and used only to capture the info used to generate the records. The second is bound and is used to view/update the generated data. Simply open this second form as the final step in your macro.
 

Users who are viewing this thread

Top Bottom