lookup combo box undo on exit

  • Thread starter Thread starter Chris B via AccessMonster.com
  • Start date Start date
C

Chris B via AccessMonster.com

Hi All,

I have a several lookup comboboxes on the same form, they lookup differant
parts of the database, these are working perfectly.
What i want is that after the user has looked up and found the record, I want
the combobox not to display anything, the reason is the user will find a
record and later scroll to another but the last lookup still remains in the
combobox, this creates confusion.

The code for one of my combobox's is:

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo16], 0))

If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub


I have tried using things like me.undo in the 'on exit' and 'on lost focus'
events but nothing happens.

Any suggestions on how to tackel this is most welcome!
Thanks
 
Try this

Me.combo16.RowSource = vbNullString
Me.combo16.Requery

Pete
 
Hi Pete,
Thanks for the prompt reply!
I gave it a try and it certainly "clears" the combobox, but if I try to use
the combobox again there is nothing there.
I tried me.requery in the "got focus" to see if that helped but it didnt.
Any other ideas?
Thanks again!!
Try this

Me.combo16.RowSource = vbNullString
Me.combo16.Requery

Pete
[quoted text clipped - 27 lines]
Any suggestions on how to tackel this is most welcome!
Thanks
 
As the focus is set back to the combo box after you have conducted the
search, if you set the value of the combo box to nothing in the gotfocus
event this will clear your combo box after the search as requested.

That is

Private Sub Combo16_GotFocus()

Me.Combo16.Value = ""

End Sub

=====================
Hope this helps
Dylan Moran
 
Hi Dylan,

This works perfectly!!!!!!

Many thanks to both of you for your assistance!!

Dylan said:
As the focus is set back to the combo box after you have conducted the
search, if you set the value of the combo box to nothing in the gotfocus
event this will clear your combo box after the search as requested.

That is

Private Sub Combo16_GotFocus()

Me.Combo16.Value = ""

End Sub

=====================
Hope this helps
Dylan Moran
[quoted text clipped - 24 lines]
Any suggestions on how to tackel this is most welcome!
Thanks
 
Glad to help mate - I am always learning too!
hence the odd nickname sometimes of 17th Century Goat-Herder

Pete
 

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

Similar Threads

Error 2237 8
Unbound Combo box Value 10
Cannot use copy record button on form with lookup box 2
Copy Record Button Function 1
msg box code 2
Search combo box 2
Textbox Filter 4
Cobo Box lookup record on a form 1

Back
Top