How can I search the recordset of a Combobox?

P

Pat

I want to be able to search for a value in a combobox and position the
combobox to that record. The app I am working on is a receiving module. The
form has a textbox for the city from the invoice and a combobox for the
location to charge against. If I could default the combobox to the value
from the textbox it would speedup processing.

The combobox has the following select statement.
SELECT dbo_Locations.LOC_NAME, dbo_Locations.PS_LOC, dbo_Locations.AP_CODE,
dbo_Locations.CITY FROM dbo_Locations ORDER BY dbo_Locations.LOC_NAME;

I would like to match the textbox txtShip_To to the dbo_Locations.CITY from
the combobox.

I have googled until my eyes have popped on this. Any help is appreciated.
 
D

Dirk Goldgar

Pat said:
I want to be able to search for a value in a combobox and position the
combobox to that record. The app I am working on is a receiving module.
The
form has a textbox for the city from the invoice and a combobox for the
location to charge against. If I could default the combobox to the value
from the textbox it would speedup processing.

The combobox has the following select statement.
SELECT dbo_Locations.LOC_NAME, dbo_Locations.PS_LOC,
dbo_Locations.AP_CODE,
dbo_Locations.CITY FROM dbo_Locations ORDER BY dbo_Locations.LOC_NAME;

I would like to match the textbox txtShip_To to the dbo_Locations.CITY
from
the combobox.

I have googled until my eyes have popped on this. Any help is
appreciated.


Something like this:

'------ start of example code ------

Dim i As Long

With Me.cboLocations ' *** substitute your combo's name

For i = 0 To (.ListCount - 1)
If .Column(3, i) = Me.txtShip_To Then
.Value = .ItemData(i)
Exit For
End If
Next i

End With

'------ end of example code ------
 
P

Pat

Perfect!!!! Thanks a TON!

Dirk Goldgar said:
Something like this:

'------ start of example code ------

Dim i As Long

With Me.cboLocations ' *** substitute your combo's name

For i = 0 To (.ListCount - 1)
If .Column(3, i) = Me.txtShip_To Then
.Value = .ItemData(i)
Exit For
End If
Next i

End With

'------ end of example code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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

Top