Preventing user changes until specified

smardonl

New Member
Joined
Jun 24, 2003
Messages
28
I have a form with several fields all related to the same table. My ultimate goal is to prevent the user from changing any fields until they select a button called btnEditRec and once they have made their changes and selected a button called btnSaveRec, the controls will all lock again. I have tried the following methods with little success or ease (form is called "Updated Data Entry Form")...

/*Loads form with no editing, changes with OnClick event*/
Private Sub Form_Load()
AllowEdits = False
AllowDeletes = False
AllowAdditions = False
DataEntry = False
End Sub

Private Sub Private Sub btnEditRec_Click()
AllowEdits = True
AllowDeletes = True
AllowAdditions = True
DataEntry = False
End Sub

/*Loads form with a snapshot record set and changes to a dynaset with OnClick event*/
Private Sub Form_Current()
Dim rs as Recordset
Forms![Updated Data Entry Form].rs=2
End Sub

Private Sub btnEditRec_Click()

Dim rs As Recordset
Forms![Updated Data Entry Form].rs = 0

End Sub

I'm sure there are ways to make my life easier. Does anyone know them? Thanks in advance,

Lindsay
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Code:
Private Sub Form_Load() 
    Call LockAll(True) ' passing True will lock all (False will unlock)
End Sub 

Private Sub FormLock(boo As Boolean)
    On Error Resume Next
    Dim ctl As Control
    For Each ctl In Me
        Me.ctl.Locked = Not boo
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,707
Messages
6,161,411
Members
451,704
Latest member
rvan07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top