V
vincentt via AccessMonster.com
Hi pals,
I have a form, set Allow* = false, so the users would not accidentally amend
the form.
On the other hand, I add a button "Edit" to set back the Allow* to True and
the button changed to "Read Only" ... however, it could not reverse back to
"Edit" after clicking on "Read Only", data could still amend. Code as follow:
Private Sub btn_edit_Click()
If btn_edit.Caption = "Edit" Then
btn_edit.Caption = "Read Only"
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
Else
btn_edit.Caption = "Read Only"
btn_edit.Caption = "Edit"
Me.AllowEdits = False
Me.AllowAdditions = False
Me.AllowDeletions = False
End If
End Sub
However, I tested the code with a newly created form, created a new button
used the same name, it works!!!
May anyone know what's the problem? Is it the problem of AutoForm?
On the other hand, I have tried to use 2 button, one is Edit, another is Read
Only. I want the Edit button would "Enable = false" after click it, and Read
Only will "Enable = true", however, I cannot make it. I think I must have
something wrong on the code....
Private Sub btn_edit_Click()
btn_readonly.Enable = True
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
btn_edit.Enable = False
End Sub
I am just new to VBA and keep trying, please help!
Thanks all in advance!
I have a form, set Allow* = false, so the users would not accidentally amend
the form.
On the other hand, I add a button "Edit" to set back the Allow* to True and
the button changed to "Read Only" ... however, it could not reverse back to
"Edit" after clicking on "Read Only", data could still amend. Code as follow:
Private Sub btn_edit_Click()
If btn_edit.Caption = "Edit" Then
btn_edit.Caption = "Read Only"
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
Else
btn_edit.Caption = "Read Only"
btn_edit.Caption = "Edit"
Me.AllowEdits = False
Me.AllowAdditions = False
Me.AllowDeletions = False
End If
End Sub
However, I tested the code with a newly created form, created a new button
used the same name, it works!!!
May anyone know what's the problem? Is it the problem of AutoForm?
On the other hand, I have tried to use 2 button, one is Edit, another is Read
Only. I want the Edit button would "Enable = false" after click it, and Read
Only will "Enable = true", however, I cannot make it. I think I must have
something wrong on the code....
Private Sub btn_edit_Click()
btn_readonly.Enable = True
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
btn_edit.Enable = False
End Sub
I am just new to VBA and keep trying, please help!
Thanks all in advance!