Discussion Locked

Active Control on form

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
What code would I need to have a command button on my active access form delete or put a null value into the current active control? The control which has the focus.

5 replies

by peyison

You really can't do this because as soon as you press the command button it becomes the active control.

What you could do is use a label, or some control that doesn't receive focus. To do this with a label, enter this code in the click event of the label control:

'--make sure that the active control can receive the null
If TypeOf Form.ActiveControl Is TextBox Then
Form.ActiveControl = null
End If

You can check for other types of controls besides TextBox. This just makes sure thatit won't crash if the active control is a command button, or something like that.

You can turn on the underline property of the label to make it appear more like something the user should click on.

Hope this helps.

by donq

Answer 1 is correct. You need to add something like "Me! = "Is Null" or "Me! = ''" (a zero length string) in the GotFocus Event of the control button.

This discussion is closed to new replies.