Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you cancel a combo box selection?

Status
Not open for further replies.

Culby

Technical User
Dec 9, 2001
13
US
When a user clicks on a combo box list and selects an item on the list, then changes their mind and wishes no selection. How do you do that? Control-click does not seem to work. Does this take special programming? s-)

Culby
 
The user only has to press the delete key to clear the combobox. In your After Update procedure for the combobox you need to test for null so that your code does not execute. Like this:

Private Sub cboClient_AfterUpdate()

Dim rst As DAO.Recordset
' If a client was selected in
' the cboClient combobox, execute
' the FindFirst function
If Not IsNull(cboClient) Then
Set rst = Me.RecordsetClone

'Find the record that matches the control
With rst
.FindFirst "[CustomerID] = '" & cboClient& "'"

If .NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = .Bookmark
End If

.Close
End With
Set rst = Nothing
End If

End Sub

John Ruff - The Eternal Optimist :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top