473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to display a query in a list box using a record set?

Can someone help? I need to execute
strSQL = "SELECT * FROM qry_viewFDOExport" when a button is pressed and
the results displayed in a list box.

I want to do something like
Dim db As Database
Dim rs As Recordset
Set rs = db.OpenRecordset(strSQL) etc and then loop through all the
results but I'm getting my head all mixed up with all the different ways
of opening/creating a recordset.
Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #1
7 4608
jim Bob wrote:
Can someone help? I need to execute
strSQL = "SELECT * FROM qry_viewFDOExport" when a button is pressed
and the results displayed in a list box.

I want to do something like
Dim db As Database
Dim rs As Recordset
Set rs = db.OpenRecordset(strSQL) etc and then loop through all the
results but I'm getting my head all mixed up with all the different
ways of opening/creating a recordset.
Thanks.

*** Sent via Developersdex http://www.developersdex.com ***


Why don't you just use...

Me!ListBoxName.RowSource = "SELECT * FROM qry_viewFDOExport"
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Jan 16 '06 #2

Because I want to get the connection going. My goal is to try to allow
the user to build the sql on the form and therefore create a custom
query so they can export whatever column they want to excel.
*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #3
jim Bob wrote:
Because I want to get the connection going. My goal is to try to allow
the user to build the sql on the form and therefore create a custom
query so they can export whatever column they want to excel.
*** Sent via Developersdex http://www.developersdex.com ***


I don't follow. What does displaying a query result in a ListBox have to do
with "exporting a column to Excel"?
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Jan 16 '06 #4
Sorry, my mistake.
I just want to allow the user to enter some text, check a few boxes etc
and then be able generate a query, and output the results to a listbox.

I can build the required SQL statement from the form. I'm just unsure
how to open a recordset, pass the sql through, read through all the rows
and output it to the listbox.

Cheers.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #5
Go back to Rick's first reply. He showed you exactly how to do it. Just
construct the SQL and set it as the RowSource for the ListBox. There is no
need to create a recordset or iterate through rows.

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"jim Bob" <fr****@gmail.com> wrote in message
news:QK***************@news.uswest.net...
Sorry, my mistake.
I just want to allow the user to enter some text, check a few boxes etc
and then be able generate a query, and output the results to a listbox.

I can build the required SQL statement from the form. I'm just unsure
how to open a recordset, pass the sql through, read through all the rows
and output it to the listbox.

Cheers.

*** Sent via Developersdex http://www.developersdex.com ***


Jan 16 '06 #6

Ah, just pass the variables from the form straight to the query
itself....

So simple that I over looked it. Doh!
Thanks guys!
*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #7

Ah, just pass the variables from the form straight to the query
itself....

So simple that I over looked it. Doh!
Thanks guys!
*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
8
by: Dan Matthews | last post by:
Hey everybody, I have an 2000 Access database that stores job listings from potential employers for a school. I would like to be able to display the date on a webpage the last time the database...
2
by: Corepaul | last post by:
As input is typed into a text box, I would like to search a recordset for the first record that matches what has been typed so far. I would like to update the text box to display the letters typed...
5
by: Lyn | last post by:
This one is difficult to explain, so I will cut it down to the basics. I have a major table 'tblA' which has an autonum field 'ID-A' as primary key (of no significance to users). 'tblA' contains...
3
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
5
by: PHPBABY3 | last post by:
Hi, 1. I have two SQL tables. I will call them employees and departments: EMP: LAST_NAME, FIRST_NAME, DEPTNM DEPT: NUM, NAME Input: text string FIND Output: the LAST_NAME, FIRST_NAME...
3
by: phil67b | last post by:
Hello everybody, I have a page rech.php where I'm doing a multi-criteria research Ex. choose your car model, choose your country. After validation of my form, on the same page, the lines will be...
20
by: raddrummer | last post by:
Hi there, I'm woking on a function that takes the input from a form (including Payroll Contact), uses it as a query parameter, runs the query, and then emaills out a custom .xls file using the...
1
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.