Blank combo box after selection

  • Thread starter Thread starter Jacqueline
  • Start date Start date
J

Jacqueline

I am building a general form where my users can lookup the codes they need
for scheduling classes.

Within each subform a combo box will allow them to lookup the data they
need, here is my question: Is there a way to reset the combo box to blank
once they have made a selection?

Right now the last selected data stays within the combo box. You can double
click to select the entire field and then type the first few letters for a
new selection, but some of my users are very limited and I would like to make
it as easy as possible.

Is this possible?
Thanks much,
Jacqueline
 
Doug where in the VB statement should I place this code? I do not work in VB
much but can find my way around. I tried putting it right after the DIM
statment but that did not work.
Thanks
 
"that did not work" doesn't give much to go on. What happened? Did you get
an error? If so, what was the error? If you didn't get an error, what did
you get (and what did you want to get instead)?

"right after the DIM statment" in what event?
 
In design mode, I clicked on the combo box and then the VB code option in the
menu, this was the code that came up for the box. I tried your code right
after the DIM statement within this sub:

Option Compare Database

Private Sub Combo18_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo18], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
Given you're trying to use the value selected in the combo box in your
FindFirst method, you can't clear the selection from the combo box until
you've done the FindFirst!

Try putting the code just before the End Sub.

If that doesn't work, please answer my question "What happened? Did you get
an error? If so, what was the error? If you didn't get an error, what did
you get (and what did you want to get instead)?"
 
Doug,
This worked, thanks. :)
Jacqueline


Douglas J. Steele said:
Given you're trying to use the value selected in the combo box in your
FindFirst method, you can't clear the selection from the combo box until
you've done the FindFirst!

Try putting the code just before the End Sub.

If that doesn't work, please answer my question "What happened? Did you get
an error? If so, what was the error? If you didn't get an error, what did
you get (and what did you want to get instead)?"

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jacqueline said:
In design mode, I clicked on the combo box and then the VB code option in
the
menu, this was the code that came up for the box. I tried your code right
after the DIM statement within this sub:

Option Compare Database

Private Sub Combo18_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo18], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
Back
Top