Blank combo box after selection

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
 
J

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
 
D

Douglas J. Steele

"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?
 
J

Jacqueline

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
 
D

Douglas J. Steele

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)?"
 
J

Jacqueline

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
 

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

Combo Box Selection is Blank 1
Combo box help 1
Combo Box question. 3
Synchronize combo boxes 2
filter query on combo box in a continuous subform 0
Combo Box Display 3
combo box selection 2
Combo Box Text 2

Top