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

Access combo box question

Status
Not open for further replies.

Oromia

Programmer
Feb 6, 2006
12
0
0
US
Hi, I have a combo box question.

Using a code I am assing a value to my combo box like this me.mycombo = prefixData

mycombo is bound to a query qryActivity.

In most cases prefixData is a prefix of a value in qryActivity, it is not the entire field.

What I am trying to accomplish is see a list of records that start with prefixData in the qryActivity (which is attached to a combobox) when prefixData is assigned to my.mycombo or when I click the arrow of the combo box.

Thanks.
 
You would be better, I think, to set the RowSource of the combobox according to the prefix:

[tt]Me.cboCombo.RowSource = "SELECT ID, Blah FROM qryActivity WHERE Blah Like '" & prefixData & "*'"[/tt]
 
I might be doing some thing wrong but it didn't work for me. The following is what I did.

Me.activity_area.RowSource = "SELECT [activity area] from qryActivityAreaLookup where [activity arera] like '" & tempActivityArea & "*'"


[activity area] is the field in the query (qryActivityAreaLookup)
qryActivityAreaLookup is the query attached to my combo box
tempActivityArea is the prefix.
activity_area is the combo box.

Thanks
 
Is that a cut-and-paste? If so, the second [activity arera] is mis-spelt; if not, in what way is it not working?
 
This may or may not be causing a problem....
Change like '" & tempActivityArea & "*'"
to like '" & tempActivityArea & "'*"


Randy
 
randy700

Are you quite sure? I have always used:

Like 'Blah*'

Not

Like 'Blah'*
 
Thank you Remou and Randy700, that part is working but it messed up the rest of the query since I don't always populate the field that way. I have worked around that issue now. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top