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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Combo Box

Status
Not open for further replies.

miaka13

Technical User
Jul 31, 2003
30
0
0
US
I'm still pretty green when it comes to Access. I'm not sure how to clear a combo box. I have a multiselect combo box that is bound to a table. The user has the capability to choose several items and then presses a command button that closes out this form and opens up another form. WHen the user goes back to the form the previously selected items are still listed. How do I clear the combo box so that when the next user opens the form, they have a "clean" combo box to work from?
 
It didn't work. :( Could it be because the combo box is in a subform?
 
Maybe, use the main form's GotFocus event to clear the subform's listbox. I think the syntax for the subform is me!SubFormControlName!Listbox

The trick is to use the name of the subform control, not the name of the subform itself.

Post back here if it still doesn't work, and I'll check again when I get back to m office later tonight.
 
I'm kind of confused. Where is the subform control?
 
With the main from in design view, select the subform and look at the name of it in the property sheet.
 
Well...I must still be doing something wrong. It's still not working. Any other suggestions? Thanks for putting up with me. :p
 
When you wrote that the listbox was in a subform, I thought you meant that form was embedded in your mainform. After rereading your original post, I think you mean just a second form that's opened.

"...and then presses a command button that closes out this form and opens up another form..."

Add the following to this command button's click event.

forms!frmName!Listbox = vbnull

substitute your form and listbox names.

Hope that helps.
 
You are right about the combo box being inside a subform. I accidentally left that part out of my original explanation. I think I found a code that works except that now it is doing something completely weird. Ok, here we go. My combo box is fueled of of a table. This is a multi-select combo box that is located inside a subform. I put the following code in the "on close" event of the subform:

Me.Combo2.SetFocus
Me.Combo2.Text = ""

This code works but now if the person selects option 1 in the drop down box, the value is not being carried over to my table. All other values are carrying over to my table with no problem. Why is is not carrying over option 1? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top