Toggle Button to Edit Form - Code Help

  • Thread starter Thread starter mmm_danone
  • Start date Start date
M

mmm_danone

On my form there is a toggle button for Edit & Read-Only modes. The
default is Read Only, so user clicks the button and can edit all
fields.

However, if you click a navigation button, or anything to get another
record up (ie filter), then the toggle button still says Edit mode, but
the form is in fact Read Only. If you click the toggle twice (to
Read-Only then back to Edit), you can edit the record ok. How can I
fix this, so the user doesn't have to toggle twice? I'd like to be
able to move from record-to-record in Edit mode.

Here's my code...

Private Sub Form_Current()
Me.AllowEdits = False
End Sub

Private Sub Form_AfterUpdate()
If Me!Toggle202 Then Me.AllowEdits = True
If Me!Toggle202 = False Then Me.Refresh: Me.AllowEdits = False
End Sub

Private Sub Toggle202_Click()
If Me!Toggle202 = True Then
Me!Toggle202.Caption = "EDIT MODE"
ElseIf Me!Toggle202 = False Then
Me!Toggle202.Caption = "READ ONLY MODE"
End If
End Sub

Private Sub Toggle202_GotFocus()
Me.AllowEdits = True
End Sub

Private Sub Toggle202_LostFocus()
Me.AllowEdits = Me!Toggle202
Me.Refresh
End Sub


TIA

Jon
 
Remove the code from the form's Current event. That is setting the form back
to read-only whenever you more record.

Whether you will be able to change the toggle button's value after you make
the form read only is another thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top