Disable keyboard

M

Martin

Hi

I have two controls on a form that I am using conditional formatting to show
the days of the week in certain colours. Becuase I am using conditional
formatting I understand the controls have to be enabled and not locked.
However I dont want the user to be able to delete any of the data.

Is there a way to disable any keybaord commands if the user happens to click
on the control? Or am I approaching this in the wrong way?

Any help would be greatly appreciated. I have tried to research this but
can't seem to find any answer.

Martin
 
J

John Spencer

I don't know why you say that the control has to be enabled and not locked.

Access 2003:

I just applied conditional formatting to a control that is locked and is not
enabled and the conditional formatting worked.

I changed to control to not locked and not enabled and conditional formatting
worked.

I changed the control to locked and enabled and conditional formatting worked.

The other option is to cancel any changes made to the control using the before
update event.
Private Sub fSubject_BeforeUpdate(Cancel As Integer)
Cancel = True
End Sub

Another option might be to use the keyup event and reset the keycode to zero.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

Jack Leach

I'm just taking a guess here, but if you were to put in your BeforeUpdate
event of the said controls a Cancel = True with no conditions, then the data
would never be updated...

Private Sub Controlname_BeforeUpdate(Cancel As Integer)
Cancel = True
End Sub

maybe there's a more appropriate way but this should certainly work

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
L

Linq Adams via AccessMonster.com

Private Sub TargetField_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = 0
End Sub

will do it as well, but as John has said, your original premise is incorrect!


Neither Enabled = False nor Locked = True prevents Conditional Formating from
working.
 

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