473,406 Members | 2,356 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,406 software developers and data experts.

Populating a listbox from a parameterized query

6
Hi, I'm having trouble trying to populate a list box with data from a parameterized query.

If I set the rowsource property to the query name, when the form opens I get the parameter values dialog, but I want to pass the params from code.

If I create a querydef, I can pass the parameter in, but I don't know how to get the records into the listbox. I have tried
Expand|Select|Wrap|Line Numbers
  1. lstNames = qdfNames.sql
Expand|Select|Wrap|Line Numbers
  1. lstNames.recordset = qdfNames.OpenRecordset;
Expand|Select|Wrap|Line Numbers
  1. rstNames = qdfNames.OpenRecordset
  2. lstNames = recordSetNames.getRows;
I feel like i'm doing something stupid, coz this should be easy, but I'm too new to access to know all its tricks.

can anyone point me in the right direction?

cheers
Aug 5 '09 #1
2 5055
MikeTheBike
639 Expert 512MB
@mcalex
Hi
You have not indicated where/how you are setting the parameters/variable(s) in code, but pehaps you could try something like this
Expand|Select|Wrap|Line Numbers
  1. lstNames.RowSource = "SELECT * FROM qryName WHERE FieldName = " & CodeVariable 
  2. lstNames.Requery
where qryName is the name of the stored querydef which should not have any perameters that you want to set in code.

??


MTB
Aug 5 '09 #2
mcalex
6
Hi Mike

I was doing something stupid. I hadn't set the RowSourceType property. It seems that as well as the RowSource, access needs to know the type before it will display data in a listbox.

As soon as I added:
Expand|Select|Wrap|Line Numbers
  1. lstNames.RowSourceType = "Table/Query"
it all worked, and nearly exactly how I expected :-)

cheers
Aug 6 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: gary b | last post by:
Hello When I use a PreparedStatement (in jdbc) with the following query: SELECT store_groups_id FROM store_groups WHERE store_groups_id IS NOT NULL AND type = ? ORDER BY group_name
6
by: Deano | last post by:
I needed to have a listbox populated by locations which are stored in tblLocations. However I wanted an "All locations" entry to be at the top of the listbox. This is not in the tblLocations. The...
8
by: deko | last post by:
I'm trying to open a Recordset based on a parameterized query. I'm kind of new to parameterized queries, so I'm sure I'm missing something simple. Set qdfs = db.QueryDefs Set qdf =...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: P K | last post by:
I have a listbox which I am populating on the client (it contains a list of dates selected from calender). The listbox is a server control. When I get to the server after postback by selecting an...
15
by: NasirMunir | last post by:
I am trying to populate a listbox from another listbox on a access form. My first listbox has names of tables on a linked odbc databse. I am trying to display the tuples of the table in the second...
0
by: redpears007 | last post by:
Morning all! :) I have a database with multiple linked tables. I have created a search form with one txt box, for entering search criteria, and a listbox for each of the tables to isplay the...
1
by: gazsharpe101 | last post by:
Hi, I have a report that is based on a query and I wish to populate a list box on the report with a value from the query based on the values of 2 other query results, i.e. if =5 and = 3 then add to...
13
tuxalot
by: tuxalot | last post by:
I have a listbox with a row source using a union query: SELECT .ReportID, .ReportName, .ReportCaption, .ReportCriteriaFlags, .ReportRemote FROM ORDER BY .ReportCaption; The union query sql: TABLE...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.