Please Help, Access DB, forms problems saving

M

michelle

Hi folks

I'm getting both confused and mad.
Lets say I have 4 records in a table.When I then save a new record in
a form I still have4 recored in the table. The first one dissapears
and the latest is added.


I have a PK which I can see in the form changes, so that is correct.


The code in my save button looks like ths:
RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec


or like this, which havs the same result
RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
DoCmd.Close


The next problem is I close a form which has already calculated data in

it whichI don't want to save I just want to close the form, the data
in the form is still saved.
Whhy??
I use this code.


DoCmd.Close


Please, please, please help me someone.
Thanks in advance

/michelle
 
D

Douglas J. Steele

Access always saves the data when you move off the record.

If you don't want it to, you have to explicitly tell it not to.

Instead of simply

DoCmd.Close

try

If Me.Dirty Then
Me.Undo
End If
DoCmd.Close
 
R

ruralguy via AccessMonster.com

On a bound form, Access *always* saves records that have changed when you
attempt to move to another record or close the form. You would need a Me.
UnDo somewhere (maybe an oops button) to keep Access from saving any changes.
Are you looking at the table when you say Access replaced an existing record
with a different one?
 
M

michelle

Thanks a lot Douglas J. Steele, that really made it.
Now I can close a form without saving the data in the form.
Thanks again !!

Now I just need to solve the other problem,
which is adding a new record in the table and still
keeping all the old records already saved in the table.

Lets say I have 4 records in a table. When I then save a new record in
a form I still have 4 records in the table. The first one disappears,
the oldest one,
and the latest is added.


I have a PK which I can see in the form changes, so that is correct.


The code in my save button looks like ths:
RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec


or like this, which have the same result
RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
DoCmd.Close

ruralguy via AccessMonster.com wrote:
Are you looking at the table when you say Access replaced an existing
record
with a different one?

My intentions is not to REPLACE a record. I'm trying to ADD a new
record.
What do I do wrong??
 
D

Douglas J. Steele

Are you typing the new information on a new line, or are you overtyping an
existing line? To have it recognized as new data, it must be on a new line.
 
M

michelle

And how is that done, I don't get it.
It's a new line with a new number one the key and all the columns are
changed it still removes the first line and and adds the the new line,
which ensd with the same number of lines as when i started.

I'm really confused.

/Michelle
 
M

michelle

I thought acNewRec makes a new line.
I have as mentioned before these 2 ways to make and save thenew line:

RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec


or like this, which have the same result
RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec

I forgot to mention that I have also tried this one:
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

So how do I make a new line?

/[email protected]
 
D

Douglas J. Steele

On your form, when you're typing the values, are you typing into a blank
line at the bottom of the form, or are you overtyping an existing line? To
add as new data, you must type on a blank line. Your code is saving the
current row, and then going to a new row.
 
M

michelle

Hi again Douglas

I can't answer your question
What I do is adding lots of new data in the form, so as well a new PK.
I want to add a new line in the table BUT when I save all the data in
the form
that the new line is added at the end of the table and the first line
in the table dissapears.
..
/Michelle

Douglas J. Steele skrev:
 

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