Home Ask Login Register

Developers Planet

Your answer is one click away!

eee333 February 2016

Way to allow users to delete textbox content but not edit it?

On my form I have a control that displays a generated ID number. I want to allow the user to delete this number (necessary to generate a new ID number), but not be able to edit it or create their own.

So far I can think of three workarounds, none ideal, and I was wondering whether anyone had a handier solution? Most of my problems come with balancing between making it easy to use the form but difficult to accidentally/carelessly delete the ID number.

Workaround #1: Keep the control disabled at all times, add a button to allow them to clear it. Downside: I already have several buttons in that area on the form and it's getting a little crowded, so I'd like to avoid that.

Workaround #2: Convert the textbox into a combobox with no options listed and edits set to no, so they can delete the information but not add any. Downside: Dropdown arrow on the control may confuse users into thinking they should actually use a combobox, would need to give them an explanatory popup message if they try to enter data and they're already encountering a lot of messages if they try to do forbidden actions/to confirm deletion of records/certain important controls.

Workaround #3: Allow them to generate a new ID number while they already have an ID number, resetting it. Downside: Again, would have to give them message interactions to confirm that they want to delete the ID number, seems a little messier than making them delete it to confirm they don't want an ID number. Worried about bordering on message fatigue meaning users wouldn't bother reading that they are deleting an existing number.

If I can't find a better workaround, I'll probably go with Workaround #2, as it seems like the least work for me. Anyone have better suggestions?


Gustav February 2016

Use the BeforeUpdate event of the textbox:

 Cancel = Not IsNull(Me!SerialNumber.Value)
 If Cancel = True Then
      MsgBox "Number can be deleted but not edited."
 End If 

Post Status

Asked in February 2016
Viewed 3,109 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life