I thought setting/changing the Row Source property would not require a requery.
I would generally not use SELECT * in a Row Source (or most everywhere else). I would specify the field names if possible.
I have used another method that uses a saved query as the Row Source. You can use a little DAO code to set the SQL property of the saved query and then open the listing form containing the search combo box.
Duane Hookom
MS Access MVP
To: MS_Access_Professionals@yahoogroups.com
From: wrmosca@comcast.net
Date: Tue, 30 Aug 2011 15:52:28 +0000
Subject: [MS_AccessPros] Re: Setting rowsource to a query in code
Connie
That's the right way to do it. But be sure to requery the combo. Changing the Rowsource is not enough to load the data.
'Set RowSource for cboSearch box
Forms!Listings.cboSearch.RowSource = strSql2
Forms!Listings.cboSearch.Requery
Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile/Bill.Mosca
--- In MS_Access_Professionals@yahoogroups.com, mrsgoudge <no_reply@...> wrote:
>
> When a button is clicked on another form I am opening the Listings form and setting the Rowsource of cbo.search (an unbound box). The code I am using is:
>
> 'Make string for Rowsource for cboSearch box
> strSql2 = "SELECT DISTINCT qListingContacts_SoldSellers.* " & _
> "FROM qListingContacts_SoldSellers;"
> 'Set RowSource for cboSearch box
> Forms!Listings.cboSearch.RowSource = strSql2
>
> Is there a better way to do this? I am just using qListingContacts_SoldSellers as the base, but the only way I knew to put it into a proper string was the above.
>
> Thanks!
> Connie
>
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MS_Access_Professionals/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/MS_Access_Professionals/join
(Yahoo! ID required)
<*> To change settings via email:
MS_Access_Professionals-digest@yahoogroups.com
MS_Access_Professionals-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
MS_Access_Professionals-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Tidak ada komentar:
Posting Komentar