473,385 Members | 2,274 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,385 software developers and data experts.

Query by form

Tom
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?

Also, is there an easy way to remove duplicates from the combo boxes?
They are getting their entries/selections from the data table and are
displaying duplicates. For example, if the data table contained 5 rows
of data with 3 men and 2 women, then the Gender combo box would contain
something like: Male, Female, Male, Male, Female.

Thanks.

Jun 29 '06 #1
12 2333

Tom wrote:
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?
Sounds like either you have a multi-column combobox and you're not
filtering on the column you think you are. Although how that would
happen in a true filter by form, I'm not sure.

Also, is there an easy way to remove duplicates from the combo boxes?


Change the SQL.

SELECT Position
FROM tblEmployees...

to

SELECT DISTINCT Position....

Jun 29 '06 #2
On 29 Jun 2006 07:23:43 -0700, Tom wrote:
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?
Are you sure the BOUND column of the combo box is the same datatype as
the Field in the query?
for example, if the City combo had "City" as text in it's bound
column, but the query Field was actually CityID ( a number datatype)?
Or Vice Versa?
Also, is there an easy way to remove duplicates from the combo boxes?
They are getting their entries/selections from the data table and are
displaying duplicates. For example, if the data table contained 5 rows
of data with 3 men and 2 women, then the Gender combo box would contain
something like: Male, Female, Male, Male, Female.

Thanks.


To remove duplicates from a combo box rowsource that is based upon a
table, create a query to select the values instea. Then change the
query SQL "Select YourTable.FieldName From TableName Order By
FieldName;" to
"Select Distinct YourTable.FieldName From TableName Order By
FieldName;"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 29 '06 #3
Tom
Adding the word "DISTINCT" to the SQL in the Row Source under
Properties for the combo boxes did not seem to make a difference. Am I
doing it wrong?

pi********@hotmail.com wrote:
Tom wrote:
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?


Sounds like either you have a multi-column combobox and you're not
filtering on the column you think you are. Although how that would
happen in a true filter by form, I'm not sure.

Also, is there an easy way to remove duplicates from the combo boxes?


Change the SQL.

SELECT Position
FROM tblEmployees...

to

SELECT DISTINCT Position....


Jun 29 '06 #4
On 29 Jun 2006 12:21:03 -0700, Tom wrote:
Adding the word "DISTINCT" to the SQL in the Row Source under
Properties for the combo boxes did not seem to make a difference. Am I
doing it wrong?

pi********@hotmail.com wrote:
Tom wrote:
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?


Sounds like either you have a multi-column combobox and you're not
filtering on the column you think you are. Although how that would
happen in a true filter by form, I'm not sure.

Also, is there an easy way to remove duplicates from the combo boxes?


Change the SQL.

SELECT Position
FROM tblEmployees...

to

SELECT DISTINCT Position....


How can anyone tell? You haven't posted your actual SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 29 '06 #5
Tom
In the design view of the recruiting survey for the gender control
combo box, my SQL code is:

SELECT DISTINCT RecruitingSurvey.ID, RecruitingSurvey.Gender FROM
RecruitingSurvey ORDER BY [Gender];

The code for the rest of the drop downs is parallel in structure...

fredg wrote:
On 29 Jun 2006 12:21:03 -0700, Tom wrote:
Adding the word "DISTINCT" to the SQL in the Row Source under
Properties for the combo boxes did not seem to make a difference. Am I
doing it wrong?

pi********@hotmail.com wrote:
Tom wrote:
Hello,

I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from drop down menus (ex. they
may select Male, New York, Manager) and those criteria will be used to
run a query (ie Query by Form). I can do this with text boxes but when
I tried to use combo boxes no records were returned in the query. Any
idea what I am doing wrong?

Sounds like either you have a multi-column combobox and you're not
filtering on the column you think you are. Although how that would
happen in a true filter by form, I'm not sure.
Also, is there an easy way to remove duplicates from the combo boxes?

Change the SQL.

SELECT Position
FROM tblEmployees...

to

SELECT DISTINCT Position....


How can anyone tell? You haven't posted your actual SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Jun 29 '06 #6
"Tom" <Th*************@gmail.com> wrote in
news:11**********************@b68g2000cwa.googlegr oups.com:
In the design view of the recruiting survey for the gender
control combo box, my SQL code is:

SELECT DISTINCT RecruitingSurvey.ID, RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

The code for the rest of the drop downs is parallel in
structure...


You do not want the recruitingSurvey.ID in the rowsource for
your ComboBox. This is why you are getting the duplicates.

SELECT DISTINCT RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

Is all you want. I know the Combobox Lizard wants to put the Id
there. If it were a Wizard it would be smart enough to know that
it's inappropriate.

Q
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jun 29 '06 #7
Tom
Bob,

I tried using that code...but then none of the choices (ex. Male,
Female) are displayed in the combo boxes on the form, just blank
spaces/lines. Any ideas? Thanks again.

Tom
Bob Quintal wrote:
"Tom" <Th*************@gmail.com> wrote in
news:11**********************@b68g2000cwa.googlegr oups.com:
In the design view of the recruiting survey for the gender
control combo box, my SQL code is:

SELECT DISTINCT RecruitingSurvey.ID, RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

The code for the rest of the drop downs is parallel in
structure...


You do not want the recruitingSurvey.ID in the rowsource for
your ComboBox. This is why you are getting the duplicates.

SELECT DISTINCT RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

Is all you want. I know the Combobox Lizard wants to put the Id
there. If it were a Wizard it would be smart enough to know that
it's inappropriate.

Q
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com


Jun 30 '06 #8
"Tom" <Th*************@gmail.com> wrote in
news:11**********************@h44g2000cwa.googlegr oups.com:
Bob,

I tried using that code...but then none of the choices (ex. Male, Female) are displayed in the combo boxes on the form, just blank spaces/lines. Any ideas? Thanks again.

Tom
Forget the Lizard, turn it off.

Set the following properties for the gender combobox as follows.
From the fromat tab
Column Count: 1
Column heads: No
List Rows: 2
Column Widths: 1";

from the Data tab.
Row source type: table/query
Row Source: "SELECT DISTINCT [Gender] from RecruitingSurvey
ORDER BY [Gender];"
Bound column: 1

the other properties: read the help, set as desired.

set the other Combobozes similarly.

Bob Quintal wrote:
"Tom" <Th*************@gmail.com> wrote in
news:11**********************@b68g2000cwa.googlegr oups.com:
> In the design view of the recruiting survey for the gender
> control combo box, my SQL code is:
>
> SELECT DISTINCT RecruitingSurvey.ID, RecruitingSurvey.Gender > FROM RecruitingSurvey ORDER BY [Gender];
>
> The code for the rest of the drop downs is parallel in
> structure...


You do not want the recruitingSurvey.ID in the rowsource for
your ComboBox. This is why you are getting the duplicates.

SELECT DISTINCT RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

Is all you want. I know the Combobox Lizard wants to put the Id there. If it were a Wizard it would be smart enough to know that it's inappropriate.

Q
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com



--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jun 30 '06 #9
Tom
I am now running a chain of 6 queries on queries from a form.
Everything works welland the results are all displayed in the final
query window. My question is whether there is a way to run the first 5
queries without having the query windows pop open. Right now I set the
first 5 queries to run and then close after the next query has used the
results of the prior query, however, the user will then still see the
first 5 windows flash open then close. I would prefer to simply have
only the results window for the 6th query pop open. Please let me know
if there is some setting that would make this possible.

Thanks,

Tom

Bob Quintal wrote:
"Tom" <Th*************@gmail.comwrote in
news:11**********************@h44g2000cwa.googlegr oups.com:
Bob,

I tried using that code...but then none of the choices (ex.
Male,
Female) are displayed in the combo boxes on the form, just
blank
spaces/lines. Any ideas? Thanks again.

Tom

Forget the Lizard, turn it off.

Set the following properties for the gender combobox as follows.
From the fromat tab
Column Count: 1
Column heads: No
List Rows: 2
Column Widths: 1";

from the Data tab.
Row source type: table/query
Row Source: "SELECT DISTINCT [Gender] from RecruitingSurvey
ORDER BY [Gender];"
Bound column: 1

the other properties: read the help, set as desired.

set the other Combobozes similarly.

Bob Quintal wrote:
"Tom" <Th*************@gmail.comwrote in
news:11**********************@b68g2000cwa.googlegr oups.com:

In the design view of the recruiting survey for the gender
control combo box, my SQL code is:

SELECT DISTINCT RecruitingSurvey.ID,
RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

The code for the rest of the drop downs is parallel in
structure...

You do not want the recruitingSurvey.ID in the rowsource for
your ComboBox. This is why you are getting the duplicates.

SELECT DISTINCT RecruitingSurvey.Gender
FROM RecruitingSurvey ORDER BY [Gender];

Is all you want. I know the Combobox Lizard wants to put the
Id
there. If it were a Wizard it would be smart enough to know
that
it's inappropriate.

Q
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com
Jul 10 '06 #10
"Tom" <Th*************@gmail.comwrote in
news:11**********************@m73g2000cwd.googlegr oups.com:
I am now running a chain of 6 queries on queries from a form.
Everything works welland the results are all displayed in the
final query window. My question is whether there is a way to
run the first 5 queries without having the query windows pop
open. Right now I set the first 5 queries to run and then
close after the next query has used the results of the prior
query, however, the user will then still see the first 5
windows flash open then close. I would prefer to simply have
only the results window for the 6th query pop open. Please
let me know if there is some setting that would make this
possible.

Thanks,

Tom
Sounds like you are trying to do do something extra. If the 6th
query calls the other five, it should automatically execute
those queries without opening any wndows. If you are also
manually executing those queries, you are doing it for nothing.


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 10 '06 #11
Tom
I am now trying to query a data table based on values the user selects
in a series of checkboxes on a form. Essentially, there are roughly 20
checkboxes on a form, all of which I want to be "yes" if they are
checked. In the corresponding data table, there is a column that
corresponds to each checkbox (roughly 20 columns). Each column is full
of "Yes" and "No" values. My question is how do you set up the
criteria so that if the user checks a specific combination of
checkboxes on the form then when you run the query only the records
with "Yes" in those columns will show up, while if they do not check
them then all values will show up?


Bob Quintal wrote:
"Tom" <Th*************@gmail.comwrote in
news:11**********************@m73g2000cwd.googlegr oups.com:
I am now running a chain of 6 queries on queries from a form.
Everything works welland the results are all displayed in the
final query window. My question is whether there is a way to
run the first 5 queries without having the query windows pop
open. Right now I set the first 5 queries to run and then
close after the next query has used the results of the prior
query, however, the user will then still see the first 5
windows flash open then close. I would prefer to simply have
only the results window for the 6th query pop open. Please
let me know if there is some setting that would make this
possible.

Thanks,

Tom

Sounds like you are trying to do do something extra. If the 6th
query calls the other five, it should automatically execute
those queries without opening any wndows. If you are also
manually executing those queries, you are doing it for nothing.


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com
Jul 17 '06 #12
"Tom" <Th*************@gmail.comwrote in
news:11**********************@m79g2000cwm.googlegr oups.com:
I am now trying to query a data table based on values the user
selects in a series of checkboxes on a form. Essentially,
there are roughly 20 checkboxes on a form, all of which I want
to be "yes" if they are checked. In the corresponding data
table, there is a column that corresponds to each checkbox
(roughly 20 columns). Each column is full of "Yes" and "No"
values. My question is how do you set up the criteria so that
if the user checks a specific combination of checkboxes on the
form then when you run the query only the records with "Yes"
in those columns will show up, while if they do not check them
then all values will show up?
You'll want to do this in the OnClickEvent code for the command
button that runs the query..

Let's generate the code, then we'll talk about querying the
result.

Dim stCriteria as String
If me.chk01 = true then
stCriteria = stCriteria & "[chk01] = true AND "
end if
If me.chk02 = true then
stCriteria = stCriteria & "[chk02] = true AND "
end if
If me.chk03 = true then
stCriteria = stCriteria & "[chk03] = true AND "
end if
' add as many as you need.

'Now strip off the final AND if there is one
If len(stCriteria 0 then
stCriteria = left(stCriteria,len(stCriteria)-5)
end if

' We now have a valid whereclause, without the 'Where'
If you are opening a form or report, use it as the 'where'
parameter of the docmd.openform method.

If you are opening the query to the user, please create a
continuous form and set it's viewmode to datasheet, and use the
..openform method.

If you are running the query as part of a .transfertext method.
you will need to have the code create/modify the query and save
it before running the .transfertext.
>

Bob Quintal wrote:
>"Tom" <Th*************@gmail.comwrote in
news:11**********************@m73g2000cwd.googleg roups.com:
I am now running a chain of 6 queries on queries from a
form. Everything works welland the results are all
displayed in the final query window. My question is
whether there is a way to run the first 5 queries without
having the query windows pop open. Right now I set the
first 5 queries to run and then close after the next query
has used the results of the prior query, however, the user
will then still see the first 5 windows flash open then
close. I would prefer to simply have only the results
window for the 6th query pop open. Please let me know if
there is some setting that would make this possible.

Thanks,

Tom

Sounds like you are trying to do do something extra. If the
6th query calls the other five, it should automatically
execute those queries without opening any wndows. If you are
also manually executing those queries, you are doing it for
nothing.


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com



--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 17 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
3
by: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
3
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings...
1
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
2
by: lindabaldwin | last post by:
Hello everyone, I am fairly new to VBA. I have a worksheet in Excel, named "Data Sheet" from which I am trying to query data. This worksheet contains the following data: unit (column A), date...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.