Form.AllowEdits = False ?

E

Eric G

I'm currently using the following code that's attached to a command
button which allows editing the last record, when the button is
clicked. The problem is that it also allows editing of all the
records.

Would someone be able to help me change this code to allow editing of
the last *and only the last* record?

If [Forms]![frmPassword]![cboUserID] =
Forms![frmTab]![frmTabDet].Form![TeacherID] Then
frmTabDet.Form.Recordset.MoveLast
frmTabDet.Form.AllowEdits = True
End If

TIA Eric
 
D

Dirk Goldgar

Eric G said:
I'm currently using the following code that's attached to a command
button which allows editing the last record, when the button is
clicked. The problem is that it also allows editing of all the
records.

Would someone be able to help me change this code to allow editing of
the last *and only the last* record?

If [Forms]![frmPassword]![cboUserID] =
Forms![frmTab]![frmTabDet].Form![TeacherID] Then
frmTabDet.Form.Recordset.MoveLast
frmTabDet.Form.AllowEdits = True
End If

You can't change *this* code to make that happen, but you can add code
to the Current event of frmTabDet to set AllowEdits to False each time
the form moves to a different record. That way, if the user switches to
a different record on the subform, AllowEdits will automatically be set
to False. Only your code will set AllowEdits to True.
 
E

Eric G

Thank you very much Dirk, it's working like a charm now!

Eric


Eric G said:
I'm currently using the following code that's attached to a command
button which allows editing the last record, when the button is
clicked. The problem is that it also allows editing of all the
records.

Would someone be able to help me change this code to allow editing of
the last *and only the last* record?

If [Forms]![frmPassword]![cboUserID] =
Forms![frmTab]![frmTabDet].Form![TeacherID] Then
frmTabDet.Form.Recordset.MoveLast
frmTabDet.Form.AllowEdits = True
End If

You can't change *this* code to make that happen, but you can add code
to the Current event of frmTabDet to set AllowEdits to False each time
the form moves to a different record. That way, if the user switches to
a different record on the subform, AllowEdits will automatically be set
to False. Only your code will set AllowEdits to True.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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