sorting uneditable fields in a datasheet

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!
 
J

John Vinson

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.
 
D

Don

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!
 
J

John Vinson

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!)
 
G

Guest

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!)


.
 
J

John Vinson

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.
 

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