Setting list box row source in VB

  • Follow


Hello,I am trying to set the row source to a query in VB so it can bedynamic depending on which option is chosen the previous form. Theuser is on a form, enters data, chooses Ok, and I want the form withthe listbox to pop up, which it does. My problem is setting the rowsource in VB. If I set the Row Source to "test1" in properties itworks fine. I've tried several ways of doing this in VB. Ideally Iwould prefer it on the previous form for an onclick event. I've triedputting 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, butnone of these work. I'm providing the same criteria in every way forthe query, so I should have results on the list box.Is there a way to do this that actually works?
0
Reply requeth 3/9/2007 6:43:08 PM

In news:1173465788.777648.113520@v33g2000cwv.googlegroups.com,requeth@gmail.com <requeth@gmail.com> wrote:> 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"-- Dirk Goldgar, MS Access MVPwww.datagnostics.com(please reply to the newsgroup)
0
Reply Dirk 3/9/2007 6:53:43 PM

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.GunnySee 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.comhttp://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.<requeth@gmail.com> wrote in message news:1173465788.777648.113520@v33g2000cwv.googlegroups.com...> 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?> 
0
Reply 69 3/9/2007 7:20:30 PM

On Mar 9, 1:20 pm, "'69 Camaro" <ForwardZERO_SPAM.To.69Cam...@Spameater.orgZERO_SPAM> wrote:> 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>> 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.>> <requ...@gmail.com> wrote in message>> news:1173465788.777648.113520@v33g2000cwv.googlegroups.com...>>>> > 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?- Hide quoted text ->> - Show quoted text -Bah, I'm always screwing up some mundane detail! (That is not amundane Detail Michael!!!)
0
Reply requeth 3/9/2007 8:01:04 PM

3 Replies
565 Views

(page loaded in 0.085 seconds)


Reply: