Setting list box row source in VB

R

requeth

Hello,

I am trying to set the row source to a query in VB so it can be
dynamic depending on which option is chosen the previous form. The
user is on a form, enters data, chooses Ok, and I want the form with
the listbox to pop up, which it does. My problem is setting the row
source in VB. If I set the Row Source to "test1" in properties it
works fine. I've tried several ways of doing this in VB. Ideally I
would prefer it on the previous form for an onclick event. I've tried
putting the horse in front and behind the cart as so:

db1.Form_searchlist.lstSearch = "test1"
DoCmd.OpenForm "searchlist"

And also:

DoCmd.OpenForm "searchlist"
Forms!searchlist!lstSearch = "test1"

I even tried making it an onload event on the searchlist form, but
none of these work. I'm providing the same criteria in every way for
the query, so I should have results on the list box.

Is there a way to do this that actually works?
 
D

Dirk Goldgar

In
Hello,

I am trying to set the row source to a query in VB so it can be
dynamic depending on which option is chosen the previous form. The
user is on a form, enters data, chooses Ok, and I want the form with
the listbox to pop up, which it does. My problem is setting the row
source in VB. If I set the Row Source to "test1" in properties it
works fine. I've tried several ways of doing this in VB. Ideally I
would prefer it on the previous form for an onclick event. I've tried
putting the horse in front and behind the cart as so:

db1.Form_searchlist.lstSearch = "test1"
DoCmd.OpenForm "searchlist"

And also:

DoCmd.OpenForm "searchlist"
Forms!searchlist!lstSearch = "test1"

I even tried making it an onload event on the searchlist form, but
none of these work. I'm providing the same criteria in every way for
the query, so I should have results on the list box.

Is there a way to do this that actually works?

Try this:

DoCmd.OpenForm "searchlist"
Forms!searchlist!lstSearch.RowSource = "test1"
 
6

'69 Camaro

Hi.
Forms!searchlist!lstSearch = "test1"

You haven't identified the RowSource Property for this combo box.
Therefore, the default property, Value, will be assigned "test1," which
doesn't work.
Is there a way to do this that actually works?

Yes. Try:

DoCmd.OpenForm "searchlist"
Forms!searchlist.lstSearch.RowSource = "test1"

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
R

requeth

Hi.


You haven't identified the RowSource Property for this combo box.
Therefore, the default property, Value, will be assigned "test1," which
doesn't work.


Yes. Try:

DoCmd.OpenForm "searchlist"
Forms!searchlist.lstSearch.RowSource = "test1"

HTH.
Gunny

Seehttp://www.QBuilt.comfor all your database needs.
Seehttp://www.Access.QBuilt.comfor Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.comhttp://www.Access.QBuilt.com/html/expert_contributors2.htmlfor contact
info.












- Show quoted text -

Bah, I'm always screwing up some mundane detail! (That is not a
mundane Detail Michael!!!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top