changing form to not allow edits

L

Linda in Iowa

I have a form just to view records and not allow edits. On the form is an
unbound combo box that shows the first and last name for each record. the
On enter event procedure of the combo box is set to allow edits so what ever
name is selected it will show that record. After selecting a record if I
click on any fields in the record I am able to edit them. I want to set the
form back to not allow edits and can't figure out where to do it. Maybe the
code I have will help.

Private Sub Combo246_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MbrID] = " & Str(Nz(Me![Combo246], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Combo246_Enter()
Me.AllowEdits = True ' allows to select record from combo list
End Sub

Private Sub Form_AfterUpdate()

Me.AllowEdits = False
Combo246.Requery

End Sub

Private Sub Form_Current()
Combo246 = MbrID

End Sub
 
D

Dirk Goldgar

Linda in Iowa said:
I have a form just to view records and not allow edits. On the form is an
unbound combo box that shows the first and last name for each record. the
On enter event procedure of the combo box is set to allow edits so what
ever name is selected it will show that record. After selecting a record
if I click on any fields in the record I am able to edit them. I want to
set the form back to not allow edits and can't figure out where to do it.
Maybe the code I have will help.

Private Sub Combo246_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MbrID] = " & Str(Nz(Me![Combo246], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Combo246_Enter()
Me.AllowEdits = True ' allows to select record from combo list
End Sub

Private Sub Form_AfterUpdate()

Me.AllowEdits = False
Combo246.Requery

End Sub

Private Sub Form_Current()
Combo246 = MbrID

End Sub


If you want the form never to allow edits except for the combo box, you
could use the combo box's Exit event to turn AllowEdits off again:

Private Sub Combo246_Exit(Cancel As Integer)
Me.AllowEdits = False ' no monkeying with other fields!
End Sub

I don't see any point in your Form_AfterUpdate event procedure if no bound
control may ever be updated.
 
A

Allen Browne

Linda in Iowa said:
I have a form just to view records and not allow edits.

Use the Locked property of the bound controls, instead of the AllowEdits
property of the form.

No code needed.
 

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

Top