By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Conditionally Change a Form's RowSource Query with VBA

P: 1
Here is a little snippet of code I wrote to speed up my data entry.

Private Sub cboName_GotFocus()

If Me!CheckBoxName = True Then
Me!cboName.RowSource = "Query1"
Else: Me!cboName.RowSource = "Query2"

End If

End Sub


This snippet allows me to enter data from different tables when needed. A checkbox value determines which Query is used for the ComboBox.

One Query inserts lists names from my "Members" table and another from my "Prospects" table. My checkbox indicates if a Member's spouse is also a Member. If not, the spouse is a "Prospect". I suppose this could be also used with an Option Group, Value List, or a ComboBox and "Case 1, Case 2, etc. There could be a number of other possible uses for this snippet.
Dec 22 '06 #1
Share this Question
Share on Google+
2 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Here is a little snippet of code I wrote to speed up my data entry.

Private Sub cboName_GotFocus()

If Me!CheckBoxName = True Then
Me!cboName.RowSource = "Query1"
Else: Me!cboName.RowSource = "Query2"

End If

End Sub


This snippet allows me to enter data from different tables when needed. A checkbox value determines which Query is used for the ComboBox.

One Query inserts lists names from my "Members" table and another from my "Prospects" table. My checkbox indicates if a Member's spouse is also a Member. If not, the spouse is a "Prospect". I suppose this could be also used with an Option Group, Value List, or a ComboBox and "Case 1, Case 2, etc. There could be a number of other possible uses for this snippet.

Can you post a reply to this thread on Wednesday/Thursday to bump it up the list. It may not get much attention over Christmas.

Happy Holidays.

Mary
Dec 25 '06 #2

MGrowneyARSI
P: 90
thanks for the code I needed to create a emp table for each user loged in and swap the for and lookups to the new table I found the RowSource is for the lookup's data and .RecordSource is for the form data at least that is how it seems kind of funny. thought i would add that in to make this thred even more usefull. thanks again.
Nov 21 '07 #3

Post your reply

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