Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and paste form/subform data

Status
Not open for further replies.

bluegnu

Technical User
Sep 12, 2001
131
0
0
GB
Hi,

I have a form with a subform attached. I was wondering if it is possible to do a mass copy and paste from an individual record in that form, including the subform data.

What I mean by that is, I open up a record which I want to copy. I press a button and it takes all the information on that record -including the subform records - and pastes an identical new record to the appropriate tables.

Is that possible? If so, how can I do it?

Thanks for any help.
 
Not possible as far as I am aware (I could be corrected)

In the past, I have used code to create a query that returns a record with a single line record with all details, and the information from the subfom concatated into a single field.

However, why do you need to copy and paste? There may be a way to avoid using it.
 
bluegnu,

you could use SQL to append the records. I don't know the information or table structure that you are working with but here is some basic code that could get you started.

1. on your form create a button to copy the info.
2. in the on click property enter the following code or a variation of:
*****************************************************
Dim SQL As String

SQL = "INSERT INTO DestinationTableHere " & _
"(DestinationField1, DestinationField2,etc... ) " & _
"SELECT OriginTable.OriginField1, " & _ "OriginTable.OriginField2, " & _
"etc... FROM OriginTableHere"
"WHERE (((OriginTable.UniqueField)= " & _ "[Forms]![SubFormName].[Form]![FormControHere]));"

DoCmd.RunSQL

End Sub
***********************************************************
Note: keep in mind this is very generic code. you need to fill in the tables and fields to make it work.

good luck
 
Thanks for the response ancb. Is there any chance you could send me an example of how this works with transferring data from the master form to the master table and subform to the subform table. Sorry, I can't work it out.

Really appreciate your help.
 
I'm not really sure how to approach it without seeing the structure of your forms and tables. I there any way you could send me a copy to look at with out any data?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top