Edit On/off Button

doddy88

Registered User.
Local time
Today, 00:15
Joined
Jul 24, 2012
Messages
26
Hi,

I have a command button in which I have turned the AllowEdits to No.

My code is:

Private Sub Command13_Click()
If Me.AllowEdits = True Then
Me.AllowEdits = False
Me.Command13.Caption = "Edit Off"
Else
Me.AllowEdits = True
Me.Command13.Caption = "Edit On"
End If
End Sub

When I open the form in form view, edits is off, I press the button and the button then says 'edit on' and I can edit my data, I finally press the button again it says 'edit off' but I cans till edit data.

Am I missing something in the code?

Regards

Dom
 
Else
Me.AllowEdits = True
Me.Command13.Caption = "Edit On"
End If
End Sub

try on the Else statement Me.AllowEdits = False

that is if you do not want to have the edits on, this should force the edits to stay off...

correct me if i'm wrong
 
I have tried switching it to false and changing the other true and false values but to no avail.

When I switch it to false, I am completely unable to edit the form.

I would like to enter the form in read-only, press the edit button to edit the form and then press the edit button again to go back into read-only.

At present it opens in read-only, I press the button and it goes into edit mode, I press it again and it remains in edit mode when I would like it to go back to read-only!

Regards
 
Is your form based on a query? If it is, can you actually edit data in the query?
 
The form was based on two tables. I have solved the issue, I have put the AllowEdits back to yes.

Button name is stored as cmdEdit and the caption is stored as Edit. Below is the code:

Private Sub Form_Current()
If Me.NewRecord Then
With Me
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.AllowEdits = True
.cmdEdit.Enabled = False
End With
Else
With Me
.AllowEdits = False
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.cmdEdit.Enabled = True
End With
End If

End Sub
Private Sub cmdEdit_Click()
Dim cap As String
cap = Me.cmdEdit.Caption
Select Case cap
Case "Edit"
With Me
.AllowEdits = True
.cmdEdit.Caption = "Lock"
.cmdEdit.ForeColor = 128
.cmdEdit.FontBold = True
.Refresh
End With
Case "Lock"
With Me
.AllowEdits = False
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.Refresh
End With
End Select
End Sub

Thanks people!
 

Users who are viewing this thread

Back
Top Bottom