Set Allowedits = false on Record Change

lilpumpkin

New member
Local time
Today, 01:08
Joined
Nov 8, 2006
Messages
3
Hi

I was just wondering if it was possible to set the Allowedits setting to false whenever someone moves to a new record.

I currently have Allowedits = No by default on form open, and an "Edit" button which sets allowedits to Yes. However, I want the form to go to Allowedits=No again when the user scrolls to a new record.

Also, is there a way to set the form so that if someone makes changes to a record, the change doesn't automatically save unless you press a save button.

Thanks
Natasha
 
I may be wrong but I don't think that you can do this;

If Me.NewRecord = True then
Me.AllowEdits = False
end if

It won't work because in a new record there is nothing to "edit" it would be empty.

I would go this way (Locking the records);

1. Put the code below behind a command button and call it cmdAllowEdits.


Code:
Dim ctrl As Control
For Each ctrl In Me.Controls
    If ctrl.ControlType = acTextBox Then
       ctrl.Locked = False
        
    End If
Next ctrl
Set ctrl = Nothing
Me.Caption = "Record Unlocked"
End Sub

Put the code below in the On Current Event of your form;


Code:
Dim ctrl As Control
For Each ctrl In Me.Controls
    If ctrl.ControlType = acTextBox Then
       ctrl.Locked = True
        
    End If
Next ctrl
Set ctrl = Nothing

Me.Caption = "Record Locked"

[/CODE]


Put the code below in the On Open event of your form:

Code:
Me.Caption = "Record Locked"


This way when the form opens all text boxes will be locked, as you move through the records they will remain locked. When you go to a New Record it will be locked. Now when you want to add or edit a record just click the Allow Edits button, the record will unlock and you can add or edit, move to the next or new record and it will be locked.

I have only set the code for text boxes if you want to use other in addition to text boxes then hold you curzor over the acTextBox in the code and push F1 then expand acControlType (4th down) and there is your list.

Hope this helps..................PS Forgot to mention that the caption of your form will indicate if the record is locked or unlocked........................PS2 Welcome to the forum...........Now Iam finished.
 

Users who are viewing this thread

Back
Top Bottom