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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicating records in form...

Status
Not open for further replies.

bearpaw

Technical User
Dec 18, 2000
2
US
Greetings:

I need to be able to duplicate all fields in a form, including recordsets in a subform and three other subforms in a tab control, and place all the data in a new form with it's autonumber. Can anyone help me with the code?

Many thanks,
Greg
 
open a recordset
Dim db as database, rst as recordset, SQL as string
Set db = CurrentDb
Set rst = db.OpenRecordset("YourNewTable")

then to get data from a main form its:
me![Textboxname]

from a subform its
me![subformname]![Textboxname]

'Add a new record
rst.addnew
rst!Name = me![Name] ' < just sample of how main form
rst!Invoice = me![subformname]![Invoice] ' < just sample of how subform
rst.update ' if you have a addnew you must have a update

'or
rst.edit 'is how to update a field
rst!name = me![Name]
'and then
rst.update 'is required when all done updating.

rst.close ' its always a good idea to close things up when all done this closes the recordset
db.close 'this closes the database


DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top