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

Find records usign a combo box in a form based on a query

Status
Not open for further replies.
Jun 4, 2001
9
US
Hi all

I have a form based on a query with some parameteres that pop up dialogue boxes to the user. After answering these "questions", the form is loaded with the records that meet the criteria.

My problem is: I created a combo box using the control wizard, telling Access that I want the combo box to look up values in a query. But when I load the form and try to use this combo to perform a search, all those "questions" from the query that is "behind" the form pop up again. That is, this combo box forces the query to be re-run, and only then I can search.

IS THERE A WAY I CAN RUN A SEARCH BY A FIELD USING A COMBO BOX IN THIS KIND OF FORM ?

P.S.: When I use this same combo box in a form based straight on a table, it runs smoothly..

Thanks a lot !!!

Miguel Oliveira
 
private sub cboComboBox_AfterUpdate()
dim rst as recordset

set rst=me.recordsetclone
'Use identifiers ' for text or # for date type field
rst.findfirst "MyField=" & me.cboComboBox
if not rst.nomatch then
me.bookmark=rst.bookmark
end if
rst.close
set rst=nothing
end sub

Aivars
 
Aivars

Thank you for your help, but the question that is inside the parameter from the query is still popping up. That is what I want to avoid... Do you know how I can do it ?

Thanks

Miguel Oliveira
 
Sounds like you need to modify your parameter query so it looks to the combo box for it's values rather than the user prompts.

In the criteria section change
[This is the user question] to

[Forms]![NameOfFormThatContainsComboBox]![ComboBoxName]

P.S. I'm assuming that your combo box is on a separate form and probably includes a button to open the form that is based on your query after the user selects values from the combo box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top