Option Button problem with AllowEdit=False

  • Thread starter Thread starter Julie
  • Start date Start date
J

Julie

I have created a form that by default when opened has
allowedits turned off so that users can 'view' data
without accidentally changing data. To allow users to
udpate data when they need to, I created an option box
with 2 selections (UnLock Data & Lock Data). When unlock
is selected, AllowEdits is updated to true, then when the
user wants to lock the data again to prevent accidental
edits, they select the Lock Data button. The data
actually does lock back up, but the option button does not
repaint, so the selection marker still looks like it is on
the unlock data, even though the data IS locked. I have
tried to repaint the form along with several other things
that just don't work. here is the current code for both
buttons, is there a way to accomplish what i'm trying to
do?

Private Sub LockData_GotFocus()
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
End If
Form.AllowEdits = False
Form.Repaint
End Sub

Private Sub UnlockData_GotFocus()
Form.AllowEdits = True

End Sub
 
Try placing a Command Button over the Option Group. Set the Transparent Property (Format
Tab) of the Command Button to True. In the OnClick event of the Command Button, toggle the
AllowEdits event and set the value of the Option Group. When the user tries to click an
option button in the group, they will really be clicking the invisible command button. You
will also need to set the Default Value of the Option Group to make sure the correct
option is "On" when the form opens.

This will allow the user to click anywhere in the Option Group's Frame to change the
selection (I stretched the invisible button over the entire frame). If you prefer, you
could use 2 buttons, one over each option button.

Sample Code:
Private Sub Command8_Click()
If Me.AllowEdits = True Then
Me.AllowEdits = False
Me.Frame2 = 1
Else
Me.AllowEdits = True
Me.Frame2 = 2
End If
End Sub
 
Back
Top