Copy a record in a form

  • Thread starter Thread starter Alex Martinez
  • Start date Start date
A

Alex Martinez

Hello,


I have a form which has a copy (duplicate) record command button I used the
wizard. I want to have this button so the user don't have to copy and paste
the same record onto a new record. Now when I press the command button all
I get is a "0" in the first field and only one other field is populated. I
have about 15 fields. My form has no restrictions at all. I don't know
what is going on. All I want to do is press a command button and copy the
record into a new record. I also like have a field called "Record Type"
when the command button is press the Record Type field get populated like
"Record Copied" to tell me if this is a copy. Is this possible. Any tips
will be appreciated. Thank you in advance.
 
Not to answer your question, but: you generally should /not/ copy a
record into a new record.

Instead, the data that is common to both the records, should be stored
in a seperate table. So, your current table structure might not be
correct.

If you want some comments on your table structure, show us the name of
each table, and list the fields in each one. (You nedn't show their
typres & lengths.)

Also, tell us what is the "primary key" of each table. If you don't
know what that is, you need to research that term! It is one of the
main concepts in a relational database like Access.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Hi TC

I work for an insurance company and I created a database to track claims.
This is all in one table the fields are:

Policy Number
Insured
Date process
Comments

What my user wants is instead of re-typing the policy number, insured, date
process, comments the user simply press the copy command button making a new
record, but within my code I will delete the date process and the comments
making those fields null. Unfortunately there is no primiary key. All I
want to do is just copy the record and making a new record. Any tips will
be appreciated. Thank You..
 
Hi Alex

To do it properly, you really need to have two tables:

tblPolicy (or whatever name you prefer)
fields:
- PolicyNumber (primary key)
- other fields pertaining to the policy as a whole; eg. DateIssued,
IssuedBy, whatever.

tblComment (or whatever)
fields:
- PolicyNumber ( composite )
- CommentDate ( primary key )
- Comment

You'd have a main form based on tblPolicy, containing a subform based
on tblComment. When you typed a new record into the subform, Access
would /automatically/ add that record to tblComment, and fill-out the
PolicyNumber field - thereby linking that new comment record, to the
"parent" policy record.

That is how you should do it in a database program like Access.
Remember: a database is not a spreadsheet. What you propose, is
suitable for a spreadsheet, but not for a database.

For example, your method allows multiple records with the same policy
number but /different Insureds/ ! The proper "database" method - as
described above - does not allow such cases to happen.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Back
Top