How to use a recordset as rowsource for a listbox

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-11-24

I am migrating an Access2k app to SQL server. The old app was feeding a list box via VBA in the style :
    query = "SELECT * FROM table"

the WHERE clause is dynamicaly constructed by a function within VBA so that on different events the listbox's rowsource is
    me.listbox.rowsource = query & createwhereclause()

The question is how can I change this in order to have the query executed on the server ?

I would be able to do the same using recordsets by I could not get the rowsource to accept the recordset as valid input.

Thanks for the help,
Question by:pbedel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8015598
I suggest you feed the listbox with a pass-thru query, which you can change programatically.

Something like this:

Dim qd As QueryDef

Set qd = CurrentDb.QueryDef("MyPassThruQuery")

qd.SQL = "Select * from table where ..."

The listbox's rowsource will never change, but you will change the SQL for the query, so you will need to requery the control:



Accepted Solution

VD earned 150 total points
ID: 8015645

Expert Comment

ID: 22381015
msdn link is no longer available

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question