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

saving record bound to fields 2

Status
Not open for further replies.

jebushatescats

IS-IT--Management
Jun 6, 2006
37
CA
I have a form that contains several textboxes that are bound to fields in a table. I want to be able to add a cmd button to the form to allow the user to save the values of the textboxes to a record and then bind the textboxes to a new record in the table. At this point the only way I know how to save the values in the form to a record is to close the form down and then reopen it to start a new record.

How can I save the values to a record and then bind the textboxes to a new record in the table

Thanks
 
DoCmd.RunCommand acCmdSaveRecord
DoCmd.runCommand acCmdRecordsGoToNew

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
A good way to learn what code is necessary for these types of operations is to use the Command Button Wizard. When you add a button to your form, the wizard pops up. Under Record Operations, you will see entries for Save Record and Add New Record, among others. Let the wizard do it's thing, then you can view the code behind the button. Before you know it, you'll be posting answers here instead of questions.

Good Luck!
 
Thanks!! that did it
One more question. When I close the form down it will create a new record containing teh values in teh textbox, is there an easy way to delete this record or prevent it from being created. In other words I don't want a record created unless the save button is selected.
Currently I am doing this on form close

Set dbs = CurrentDb
Set rs1 = dbs.OpenRecordset("tblElement", dbOpenDynaset)
rs1.FindFirst ("DocID = " & "'" & txtDocID & "'")
rs1.Delete
Set rs1 = Nothing

txtdocid contains the value that is the unique key field for the record

Thanks again
 
rjoubert thanks for the reply, I will spend some time playing with the command button wizard
 
Have a look at the BeforeUpdate event of the Form object and at it Cancel argument.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top