Button to Commit Edits

Tezcatlipoca

Registered User.
Local time
Today, 16:18
Joined
Mar 13, 2003
Messages
246
Hi All,

Ok, simple layout. I have a form with a unbound textbox on it called txtData.
This has a control source of the field fldData in the table tblData. This field in the table contains alphanumeric data. All nice and simple so far.

Now the textbox is set to be unenabled when the form is loaded. There is a button on the form called btnEdit. Clicking this button simply fires a 'Me.txtData.Enabled = True' command then sets the focus into that box, ready for the user to edit the data directly.

Now here's the tricky bit. I want to introduce a second button that allows the user to commit their changes. Eventually, this button will have a load of validation code to other objects on the form to ensure that a bad record cannot be saved, but for now I need to know how I can introduce a function that allows the user to click Edit and change the data in the field Data of tblData, but these changes should not be saved to the table until that Save button is clicked.

I know I can do this in a very sloppy way by presenting the user with a second textbox when they click edit that is populated with the contents of the table field but isn't controlled by the table field. The user then works on a copy which doesn't get saved to the table until a second button is clicked.

This solution is easy to implement, but there has to be a cleaner, neater way to do this, surely?
 
I think the sloppy way is going to be the best - make you enable button enable an unbound text box, which when you click the save button copies the text entered into a hidden, bound text box.
 
I think the sloppy way is going to be the best - make you enable button enable an unbound text box, which when you click the save button copies the text entered into a hidden, bound text box.

Yeah, that's exactly what I was thinking. It means adding extra unbound boxes for the user to be working on before the final save, but is safer I guess since the table data isn't being directly manipulated.

Just wondered if there was a cleaner way with less code. Oh well, not really a problem.

Thanks
 
I guess the other way to do it would be to have your save button just close the form, and a cancel button to clear/delete the record.
 

Users who are viewing this thread

Back
Top Bottom