Choosing a record in a Combo Box

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

How do you make the related fields on a form appear as you type the
value in a combo box...now they only appear if I hit Enter or choose
them from the dropdown List.
Thanks
DS
 
What you describe is normal operation of a combobox control used as a
lookup/filter. Normally, the combobox has its "Auto Expand" property set to
YES so that the closest match (from the combobox record source) is selected
as you type. Then pressing "Tab" or "Enter" after data entry is finished,
fires the After Update code to locate/display the related record.

If you really insist on displaying/changing the related record as you enter
each character into the combobox, then move that same code from the After
Update event to the On Dirty or On Change event, but I think that you'll
find the changing record displays annoying.
-Ed
 
DS, you have to hit enter to make such related data appear on the data value
you choose from the combo box. Perhaps I don't understand your question.
The combo box/list has a "on enter" feature that runs the code after a
selection is made and confirmed by hitting the Enter button. What is it you
are trying to do?

Destin Richter
(e-mail address removed)
 
Destin said:
DS, you have to hit enter to make such related data appear on the data value
you choose from the combo box. Perhaps I don't understand your question.
The combo box/list has a "on enter" feature that runs the code after a
selection is made and confirmed by hitting the Enter button. What is it you
are trying to do?

Destin Richter
(e-mail address removed)

:
I have a form with a Combobox on the header to select a record.
On the main part of the form I have the "ItemID" and one other field
called "About" As you select a record from the Combobox I want the Main
Fhat orm to update itself and show the first record that meets that
criteria. For example if I type M, I want to see the first record
starting w/ M, then as I type further, lets say now I have MA I want to
see the first record that meets the criteria MA...so on and so forth. I
hope I'm clearer.
Thank You
DS
 
My combo box search form does exactly what you are talking about, matching an
existing record as I type in the name I am searching for...not sure why you
are getting a different respone.
 
Destin said:
My combo box search form does exactly what you are talking about, matching an
existing record as I type in the name I am searching for...not sure why you
are getting a different respone.

:
I have this on the After Update of the Combobox

Private Sub Combo15_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ItemID] = " & Str(Nz(Me![Combo15], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I have this on the On Current of the Form.
Me.Requery

Am I missing something?
Thanks
DS
 
DS said:
Destin said:
My combo box search form does exactly what you are talking about,
matching an existing record as I type in the name I am searching
for...not sure why you are getting a different respone.

:
I have this on the After Update of the Combobox

Private Sub Combo15_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ItemID] = " & Str(Nz(Me![Combo15], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I have this on the On Current of the Form.
Me.Requery

Am I missing something?
Thanks
DS
PS from DS
I want the from to Update as I type without hitting Enter.
Thanks
DS
 
DS said:
PS from DS
I want the from to Update as I type without hitting Enter.
Thanks
DS

Then you need to use the Change event, not AfterUpdate and you might have to use
the Text property of the control instead of the Value property (which being the
default is what you get when you just use the control name by itself).
 
Rick said:
Then you need to use the Change event, not AfterUpdate and you might have to use
the Text property of the control instead of the Value property (which being the
default is what you get when you just use the control name by itself).
I tried putting my code on Change, made it worse. Heres my new code...


On Error Resume Next

cbName.SetFocus
If cbName.Value > 0 Then
Me.Filter = "[CustomerID]=" & cbName.Value
Me.FilterOn = True
cbAddress = ""
cbTel = ""
End If

I have 3 Combo boxes so that they can choose a customer by name, address
or telephone number, this all works great now the only thing that I am
missing is that as I type the criteria in I want the record to fill in.
I've searched the net and people have mention this but...no code.
Thanks
DS
 
DS said:
Rick said:
Then you need to use the Change event, not AfterUpdate and you might have to
use the Text property of the control instead of the Value property (which
being the default is what you get when you just use the control name by
itself).
I tried putting my code on Change, made it worse. Heres my new code...


On Error Resume Next

cbName.SetFocus
If cbName.Value > 0 Then
Me.Filter = "[CustomerID]=" & cbName.Value
Me.FilterOn = True
cbAddress = ""
cbTel = ""
End If

I have 3 Combo boxes so that they can choose a customer by name, address or
telephone number, this all works great now the only thing that I am missing is
that as I type the criteria in I want the record to fill in.
I've searched the net and people have mention this but...no code.
Thanks
DS

As I stated before, In the Change event you cannot use the Value property
because that is not updated until the Update events fire. You have to use the
Text property which holds the changed (but not yet updated) value of the
control.
 
Rick said:
Rick Brandt wrote:

DS wrote:


PS from DS
I want the from to Update as I type without hitting Enter.
Thanks
DS


Then you need to use the Change event, not AfterUpdate and you might have to
use the Text property of the control instead of the Value property (which
being the default is what you get when you just use the control name by
itself).

I tried putting my code on Change, made it worse. Heres my new code...


On Error Resume Next

cbName.SetFocus
If cbName.Value > 0 Then
Me.Filter = "[CustomerID]=" & cbName.Value
Me.FilterOn = True
cbAddress = ""
cbTel = ""
End If

I have 3 Combo boxes so that they can choose a customer by name, address or
telephone number, this all works great now the only thing that I am missing is
that as I type the criteria in I want the record to fill in.
I've searched the net and people have mention this but...no code.
Thanks
DS


As I stated before, In the Change event you cannot use the Value property
because that is not updated until the Update events fire. You have to use the
Text property which holds the changed (but not yet updated) value of the
control.
Ok Rick, Just one question...how do I use the text property with the
code above? Thank you for your patience.
DS
 

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

Back
Top