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!

HELP!! Combo Box / Form / Query Question...!

Status
Not open for further replies.

obaluba

Technical User
Sep 24, 2001
49
GB
Hello,
I have a Combo box within a form which is run from a basic query.
What i want to do is the user to get the name they want from the combo box, then click ok and a macro is run which will run a query which will present the results within a form.
The only bit i am unsure of is, What code do you put in the criteria of the Query which the combo box is based on which makes it searchable?
i mean in others i have put things like:
[Form]![Company]![text0]
is it something similar to this?

please help if you can!

Rob
 
If its a single column combo box, you should be able to use something like:
Code:
[Forms]![Company]![YourComboBox]

If its a multi-column one, use the column property, with 0 referring to the first column, 1 the second, etc.
Code:
[Forms]![Company]![YourComboBox].Column(0)

HTH
 
Ok I tried what you said and had no success.
I know its something simple i think. The database itself is a simple one. The query is on one table and the combo box is a single one displaying all the results of one column. When the correct name is in the combo box i want to be able to press ok and the information regarding the person comes up via a form. I am sure this is something in the criteria of the query....
CosmoKramer, if you have any more suggestions i would be very grateful!!
thanks
Rob
 
Rob,

Set up an invisible text box on your form called txtTextBox and add code like this to the On Click event of your button:
Code:
Dim strCriteria As String

txtTextBox = Forms![Company]![cboComboBox].Column(0)
strCriteria = "[CompanyField] = forms![Company]!txtTextBox"

DoCmd.OpenForm "frmYourForm", , , strCriteria

HTH
 
Thanks very much, that worked...and its all sorted now!

Thanks again!
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top