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

displaying the results of a query in a listbox

Status
Not open for further replies.

Maggie24

IS-IT--Management
Jun 29, 2004
36
IE
hello all!

On my form I have a button that runs a search query - I want to display the results of the query on my form for my further manipulation on a listbox. how can i do this??

Or can you guys think of a better way??

cheers

Maggie May
 
Why not create a subform based on the query, in DataGrid view?
 
You can put the query name as the RowSource for your listbox and it will display the columns for selection. When you say manipulation you will have to explain more if you want recommendations concerning how to do whatever you want to do to the recordset. List boxes basically just display recordsets. A SubForm control displays in a continuous form all the rows of a recordset(table/query). If you want to change data in a recordset then a listbox is not the way to go but rather use a subform.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
you can just set the recordsource of the list box to the query...

also, you might have to increase the number of columns displayed, or the title of the columns in the properties of the list box...

as for any better ways of doing this, well, what are you trying to do with this in the first place?
 
thanks for the info - basically

i want to use a button to run my query as i dont want it to open as soon as the form opens.

The query is a serch which query which returns a number of records based on a word.

I then want to be able to add data to one column in the rows returned in the subquery.

is there anyway i can have a subform whihc displays the results of my button query in the form of a table on the subform???

 
you see if i put the query in rowsource of the listbox as described - the query textbox appears as soon as the form is opened which i dont want..... i want to press a button on the form to run the query and have the results displayed in table format on the form.

hope i am exaplaining myself okay,

all help is appreciated!
 
Yes, you can have that happen. Lookup and see how to create a subform and a subform control on your main form. By creating an underlying continuous type subform you can display the rows of records like they are being displayed when you open a table in datasheet view. You can remove the form from the subform control to start the form out. Then a click of the command button we can put code in to reinsert the form designation in the subform properties and display the selected records.

My question is Why??. What are going to do between the opening of the form and the displaying of the records?

Please post back with a discussion of how and what you want this form to do. Then we can give you some proven techniques to use.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top