View Full Version : Saving data in form as a new record in a table


izman23
03-24-2000, 03:12 PM
I have a form who's record source is a query. The user enters in two pieces
of data and then clicks on a command button (Go Look).

Once the record is located a second form is presented to the user with all
the data fields populated with that records information. The user can
overwrite information and then save it with a command button.

PROBLEM IS:

How can I set this up so that when the user overwrites information to record
the original information is stored and the overwritten data along with all
other data that wasn't changed is saved as a new record.

Here is some of the code that I've been working with. I get an debug
error 3020, trying to update or edit a record without using update or adnew.

GENERAL DECLARATION

DIM OldRec AS DAO.RECORDSET
DIM ModRec as DAO.RECORDSET


PRIVATE SUB FORM LOAD

SET OLDREC = FORM.RECORDSETCLONE

END SUB

SUB COMMANDSAVE_CLICK
Dim X as integer
SET MODREC = FORM.RECORDSETCLONE
for x = 0 to form.recordsetclone.fields.count -1
FORM.RECORDSETCLONE(X) = oldrec(x)
next x

FORM.RECORDSETCLONE.ADDNEW

for x = 0 to form.recordsetclone.fields.count -1
FORM.RECORDSETCLONE(X) = Modrec(x)
next x

FORM.RECORDSETCLONE.UPDATE
END SUB

Please, any help would be much appreciated.

Travis
03-24-2000, 06:19 PM
I think this is what you want:

(Feel free to correct me if I'm wrong)

You want to first bring up information on an existing record. You then open a second form in which the last entry is displayed. You want to allow the user to change information in this form and save it as a new record, leaving the original record alone.

If this is correct, try this.

First Bind the Second form to the Table. Open the Second form as DataEntry = True. Then populate the fields with the old data. This will create your new record leaving the old one intact.