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

Making a combo box that lists fields in a Query 2

Status
Not open for further replies.

Modex

Programmer
Sep 15, 2002
155
GB
Hi all,

I cant work this one out, I wonder if it can be done.

I Have a query with a number fields and a form with blank unbound boxes, I would like to use the combo box to select what fields to use in the form.

But I just do not know how to list the queries field names in a listbox/combobox.

Any help would be gratefully received

Cheers

ModeX
 
Hi Modex,

open a recordset using for source the query. The
recordset.fields(i).name returns the name

Adding the fields to the combo

For i=0 to recordset.fields.count -1
combobox.addnew recordset.fields(i).name
Next i
 
Or simply set the RowSourceType to Field list.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hello and good afternoon,

I read the request with great interest because I am trying to do the same thing. When I write the query now, I put this statement in the criteria "Like [Enter PM Name]". This makes a box pop up with a place to type the name. It works fine if the user knows how to spell the name correctly. But if not then the report based on the query comes up blank.
What I would like the query to do is, instead of asking for the name, a list box drops down and the user selects one from the list.
How can I do this?

Thanks

SuePee

[hairpull2]


Same Circus, Different Clowns
 
Simply use a parameter form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi JerryKlmns and PHV,

Many Thanks for your anwsers they both worked a treat, when I get back to work, I'll put them into action.

Thanks Again ModeX.

Also for SUEPee what you could put in the query parameter in place of

like [Enter PM Name]

you could put

Like * & [Enter PM Name] & *

That way the user only needs to put in a partial part of the name, just a thought, maybe it may be useful.

Cheers

ModeX
 
SuePee,

Create a form (frmCriteria), add a list box (lstPM_Names), set the RowSource of the list box to:

SELECT DISTINCT PM_Name FROM Table

Change the query of your report from:

WHERE PM_Name Like [Enter PM Name]

To:

WHERE PM_Name = frmCriteria!lstPN_Names
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top