Is there a way to make the form not updatable unless the "Update"button is pressed?

  • Thread starter Thread starter Rhonda Floyd
  • Start date Start date
R

Rhonda Floyd

I have a user that will start entering data on a form and press "Close" and the data that was entered updates the database.

I'm not exactly sure what I need to do to code this feature in. I only want the Table to be updated with new data or changed data when the "Update" command button is pressed.

Any help will be greatly appreciated.

Thanks.
 
does your form have subforms? Do you have anything other than labels and
textboxes?
assuming no to both, follow these steps:

1. Add a module level OkToUpdate as Boolean

2. Attach the following code to the form's BeforeUpdate event
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
if Me.Dirty and Not OkToUpdate then
For Each ctl in Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = ctl.OldValue
End If
Next Ctl
End If
End Sub

3. attach the following to the update button

OKToUpdate = True
DoCmd.GoToRecord , , acNewRec ' or AcNext etc

if you have comboboxes etc, this gets a bit more complicated..




I have a user that will start entering data on a form and press "Close" and
the data that was entered updates the database.

I'm not exactly sure what I need to do to code this feature in. I only want
the Table to be updated with new data or changed data when the "Update"
command button is pressed.

Any help will be greatly appreciated.

Thanks.
 
Thanks, luckily my form isn't complicated.

Thanks again for your help.
Rhonda
does your form have subforms? Do you have anything other than labels and
textboxes?
assuming no to both, follow these steps:

1. Add a module level OkToUpdate as Boolean

2. Attach the following code to the form's BeforeUpdate event
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
if Me.Dirty and Not OkToUpdate then
For Each ctl in Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = ctl.OldValue
End If
Next Ctl
End If
End Sub

3. attach the following to the update button

OKToUpdate = True
DoCmd.GoToRecord , , acNewRec ' or AcNext etc

if you have comboboxes etc, this gets a bit more complicated..




I have a user that will start entering data on a form and press "Close" and
the data that was entered updates the database.

I'm not exactly sure what I need to do to code this feature in. I only want
the Table to be updated with new data or changed data when the "Update"
command button is pressed.

Any help will be greatly appreciated.

Thanks.
 
Back
Top