473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Conditionally Change a Form's RowSource Query with VBA

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
2 4111
MMcCarthy
14,534 Expert Mod 8TB
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
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

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

Similar topics

1
by: Shaun | last post by:
Hi all Ok here is the big question, have a form that was bound to a now large database (Access 2002 client / server split) and I was accessing various records based on using applyfilter. Now to me...
4
by: john | last post by:
I created a form via the wizard with 1 main table and 2 one-on-one tables. As i couldn't add a field to the form (a field that I added to the table after creating the form), I googled out that the...
4
by: reidarT | last post by:
I have a dataset with 2 tables. I have madee a query of theese 2 tables. When I look at the datasources the query is not shown. How do I make a form with the query as source? reidarT
10
by: sesling | last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have...
1
by: jmarr02s | last post by:
When I double click on my form..I get a Parameter Query box. How can I turn this off?! I went to properties, but did not see anything that would help remove this. I also deleted the query...
1
by: starke1120 | last post by:
Is there a way to open a form based on query type.. Example.. If a certain query result is 1 then open the form to this result.. If the query results are NULL or 0 results, then open open for...
0
by: madeofrose | last post by:
How can i change classic asp pages' query string syntax? ------------------------------------------------------------------------------------ Hi i give a sample below original query string :...
7
by: bluray | last post by:
I have been fighting with this for a while, and I know someone on this board will be able to figure it out in a split second :) I have a List Box and a Combo Box. Based on the selection the user...
2
by: CharlieUK | last post by:
I have a button on a Client form that opens a form with a query as filter. If the query filters no records then the form comes up blank and doesnt even show the close button. Im trying to use code to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.