sorting uneditable fields in a datasheet

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I have fields on a datasheet form that are NOT editable
and others that are. The ones that are NOT editable will
not allow sorting on the datasheet. If I change the field
to Enable=Yes, then the column can be sorted. But this
makes the field editable. The user wants the datasheet,
wants to sort on uneditable fields and wants the
uneditable fields to stay uneditable. Is there a way to
do this? I'm using Access 2002.

THANKS! in advance!
 
I have fields on a datasheet form that are NOT editable
and others that are. The ones that are NOT editable will
not allow sorting on the datasheet. If I change the field
to Enable=Yes, then the column can be sorted. But this
makes the field editable. The user wants the datasheet,
wants to sort on uneditable fields and wants the
uneditable fields to stay uneditable. Is there a way to
do this? I'm using Access 2002.

THANKS! in advance!

Not in a datasheet, at least not to my knowledge. You might *try* this
(no guarantees): open the form in design view (as a Form, not a
datasheet); on each such field's BeforeUpdate event put the following
code:

Private Sub fieldname_BeforeUpdate(Cancel as Integer)
Me.fieldname.Undo ' undo any changes the user has made
End Sub

This *should* just quietly undo any changes that the user has made.
 
I tried this but it didn't do anything. I may not have
done it correctly. I add your lines in the Code Builder.
Is this the correct place? Any other details will be
helpful. Thank you so much for your help!
 
I tried this but it didn't do anything. I may not have
done it correctly. I add your lines in the Code Builder.
Is this the correct place? Any other details will be
helpful. Thank you so much for your help!

You need to use your own field names, of course. Could you post the
name of the field, the name of the control, and the actual VBA code
you implemented? Does the event property show [Event Procedure]? If
you open the form as a Single or Continuous form, does it work? (the
event might not fire in a datasheet, I really don't know!)
 
Here is the code:

Private Sub LetterNumber_BeforeUpdate(Cancel As Integer)

Me.LetterNumber.Undo ' undo any changes the user has made

End Sub

The field name is LetterNumber. I left the name of the
code as [Event Procedure].

Thank you so much for your help!

-----Original Message-----
I tried this but it didn't do anything. I may not have
done it correctly. I add your lines in the Code Builder.
Is this the correct place? Any other details will be
helpful. Thank you so much for your help!

You need to use your own field names, of course. Could you post the
name of the field, the name of the control, and the actual VBA code
you implemented? Does the event property show [Event Procedure]? If
you open the form as a Single or Continuous form, does it work? (the
event might not fire in a datasheet, I really don't know!)


.
 
Here is the code:

Private Sub LetterNumber_BeforeUpdate(Cancel As Integer)

Me.LetterNumber.Undo ' undo any changes the user has made

End Sub

The field name is LetterNumber. I left the name of the
code as [Event Procedure].

Thank you so much for your help!

Does the form still allow the user to update LetterNumber? If so,
evidently a Datasheet won't work.

An alternative might be to use the Form's BeforeUpdate event; undo
each control which should be read-only.
 
Back
Top