Allow additions but disable already entered data

C

Chris Finke

How can I disable some of the fields in an Access form so that they
are not accidentally edited, but still allow new records to be created
through the form? As of now, only the non-disabled fields can be
added.
 
A

Allen Browne

Use the Current event of the form, to set the Enabled properties of the
controls, based on whether it is a new record:

Private Sub Form_Current()
Dim bAllow As Boolean

bAllow = Me.NewRecord

Me.SomeField.Enabled = bAllow
Me.AnotherField.Enabled = bAllow
'etc.
End Sub
 
C

Chris Finke

Allen Browne said:
in message


Use the Current event of the form, to set the Enabled properties of the
controls, based on whether it is a new record:

Private Sub Form_Current()
Dim bAllow As Boolean

bAllow = Me.NewRecord

Me.SomeField.Enabled = bAllow
Me.AnotherField.Enabled = bAllow
'etc.
End Sub

Thanks; this worked perfectly, although I chose to change it to

Me.SomeField.Locked = Not bAllow

so that the fields would not be grayed out, and thus, easier to read.

For anyone who reads this in the future for reference, I'm using
Access 2000 connecting to an MSSQL 2000 server.
 

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