On Lost Focus

P

Paul Hammond

I need to require the user to select a value from a
dropdown before taking any other actions. My solution
was to make this control the first tab stop, then add the
follow code to the On Lost Focus event.

Private Sub cboPublication_LostFocus()
If IsNull(Me.cboPublication) Or
Me.cboPublication = "" Then
MsgBox "Please select a publication
from the dropdown box."
Me.cboPublication.SetFocus
End If
End Sub

The problem is that SetFocus action does not take
place. After clearing the message box, whatever control
they click on or tab to gets the focus. Does anybody
know why this doesn't work?

TIA

Paul Hammond
Richmond VA
 
V

Van T. Dinh

Try using the cbo_Exit Event instead. The Exit Event happens before the
LostFocus Event and it can also be cancelled which means that the Focus
remains on the ComboBox.

Check Access Help on the Exit Event of a ComboBox Control.
 
P

Paul Hammond

Thanks, that worked.

Paul
-----Original Message-----
Try using the cbo_Exit Event instead. The Exit Event happens before the
LostFocus Event and it can also be cancelled which means that the Focus
remains on the ComboBox.

Check Access Help on the Exit Event of a ComboBox Control.

--
HTH
Van T. Dinh
MVP (Access)





.
 

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