query criteria from form

Hi,    
   I have a table that contains many yes/no fields.   "Attribute 1", 
"Attribute 2", "Attribute 3", etc.   I would like to set up a query whose 
criteria for these fields comes from a form with a check box for each field.  
I tried using a reference to a check box control on a form as the criteria in 
the query.  For example, the criteria for "Attribute 1" in the query would be 
[forms]![formname].[Attribute 1]  I named the control after the field.  The 
problem with this is, since every field has this criteria, if Attribute 1 is 
checked on the form the query will return all records with a "yes" value in 
this field, but if any other attribute fields are also "yes", that record is 
not included.  I want those records included as well.  Can someone tell me 
how to construct a query that will do this?  I also need to be able to check 
multiple boxes on the form and return records that have a "yes" for all those 
boxes, but also not exclude any records that may have additional fields that 
contain a "yes".

thanks

0
Utf
2/27/2008 12:36:49 AM
access 16762 articles. 3 followers. Follow

6 Replies
503 Views

Similar Articles

[PageSpeed] 17

On Tue, 26 Feb 2008 16:36:49 -0800, Jake <Jake@discussions.microsoft.com>
wrote:

>Hi,    
>   I have a table that contains many yes/no fields.   "Attribute 1", 
>"Attribute 2", "Attribute 3", etc. 

Then you have an incorrectly designed table. "Fields are expensive, records
are cheap"! What if you need to add a new attribute? Redesign your table,
redesign all your queries that use the table, redesign all your forms and
reports? OUCH!

>  I would like to set up a query whose 
>criteria for these fields comes from a form with a check box for each field.  
>I tried using a reference to a check box control on a form as the criteria in 
>the query.  For example, the criteria for "Attribute 1" in the query would be 
>[forms]![formname].[Attribute 1]  I named the control after the field.  The 
>problem with this is, since every field has this criteria, if Attribute 1 is 
>checked on the form the query will return all records with a "yes" value in 
>this field, but if any other attribute fields are also "yes", that record is 
>not included.  I want those records included as well.  Can someone tell me 
>how to construct a query that will do this?  I also need to be able to check 
>multiple boxes on the form and return records that have a "yes" for all those 
>boxes, but also not exclude any records that may have additional fields that 
>contain a "yes".

If you insist on using this flawed, wide-flat design, then you'll need a
criterion on each field of

=Forms!yourform!Attribute3 OR Forms!yourform!Attribute3 = False

The query grid will get REALLY REALLY UGLY (with as many calculated fields as
you have checkboxes, and many, many OR lines).

A normalized design will have three tables to model the many to many
relationship. Let's say you have a table Entities, a table Attributes (with
one record for each of your AttributeN fields), and a tall thin table
EntityAttributes with fields EntityID, AttributeNo, and AttributeValue (a
yes/no field) - or you could simply take the existance or nonexistance of a
record as the value. Your query then becomes trivial - find all records in
EntityAttributes with the desired AttributeNo values.
-- 
             John W. Vinson [MVP]
0
John
2/27/2008 3:00:16 AM
Thanks for the reply.  I did not set up this table the way it is.  It is 
Medicare member information given to us by the government.  There are 
actually 75 different "attribute" fields, and just over 60,000 records.  Is 
there any efficient way to take the information from this table and construct 
tables as you have described?

thanks

"John W. Vinson" wrote:

> On Tue, 26 Feb 2008 16:36:49 -0800, Jake <Jake@discussions.microsoft.com>
> wrote:
> 
> >Hi,    
> >   I have a table that contains many yes/no fields.   "Attribute 1", 
> >"Attribute 2", "Attribute 3", etc. 
> 
> Then you have an incorrectly designed table. "Fields are expensive, records
> are cheap"! What if you need to add a new attribute? Redesign your table,
> redesign all your queries that use the table, redesign all your forms and
> reports? OUCH!
> 
> >  I would like to set up a query whose 
> >criteria for these fields comes from a form with a check box for each field.  
> >I tried using a reference to a check box control on a form as the criteria in 
> >the query.  For example, the criteria for "Attribute 1" in the query would be 
> >[forms]![formname].[Attribute 1]  I named the control after the field.  The 
> >problem with this is, since every field has this criteria, if Attribute 1 is 
> >checked on the form the query will return all records with a "yes" value in 
> >this field, but if any other attribute fields are also "yes", that record is 
> >not included.  I want those records included as well.  Can someone tell me 
> >how to construct a query that will do this?  I also need to be able to check 
> >multiple boxes on the form and return records that have a "yes" for all those 
> >boxes, but also not exclude any records that may have additional fields that 
> >contain a "yes".
> 
> If you insist on using this flawed, wide-flat design, then you'll need a
> criterion on each field of
> 
> =Forms!yourform!Attribute3 OR Forms!yourform!Attribute3 = False
> 
> The query grid will get REALLY REALLY UGLY (with as many calculated fields as
> you have checkboxes, and many, many OR lines).
> 
> A normalized design will have three tables to model the many to many
> relationship. Let's say you have a table Entities, a table Attributes (with
> one record for each of your AttributeN fields), and a tall thin table
> EntityAttributes with fields EntityID, AttributeNo, and AttributeValue (a
> yes/no field) - or you could simply take the existance or nonexistance of a
> record as the value. Your query then becomes trivial - find all records in
> EntityAttributes with the desired AttributeNo values.
> -- 
>              John W. Vinson [MVP]
> 
0
Utf
2/27/2008 2:21:02 PM
Jake,

You may be able to do that with the Excel-Access Converter Utility.
See this site :-
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='Excel%20to%20Access%20Converter%20Utility%20program'
There is a version for Access 2000/2 and Access 2003.

HTH

Peter Hibbs.

On Wed, 27 Feb 2008 06:21:02 -0800, Jake
<Jake@discussions.microsoft.com> wrote:

>Thanks for the reply.  I did not set up this table the way it is.  It is 
>Medicare member information given to us by the government.  There are 
>actually 75 different "attribute" fields, and just over 60,000 records.  Is 
>there any efficient way to take the information from this table and construct 
>tables as you have described?
>
>thanks
>
>"John W. Vinson" wrote:
>
>> On Tue, 26 Feb 2008 16:36:49 -0800, Jake <Jake@discussions.microsoft.com>
>> wrote:
>> 
>> >Hi,    
>> >   I have a table that contains many yes/no fields.   "Attribute 1", 
>> >"Attribute 2", "Attribute 3", etc. 
>> 
>> Then you have an incorrectly designed table. "Fields are expensive, records
>> are cheap"! What if you need to add a new attribute? Redesign your table,
>> redesign all your queries that use the table, redesign all your forms and
>> reports? OUCH!
>> 
>> >  I would like to set up a query whose 
>> >criteria for these fields comes from a form with a check box for each field.  
>> >I tried using a reference to a check box control on a form as the criteria in 
>> >the query.  For example, the criteria for "Attribute 1" in the query would be 
>> >[forms]![formname].[Attribute 1]  I named the control after the field.  The 
>> >problem with this is, since every field has this criteria, if Attribute 1 is 
>> >checked on the form the query will return all records with a "yes" value in 
>> >this field, but if any other attribute fields are also "yes", that record is 
>> >not included.  I want those records included as well.  Can someone tell me 
>> >how to construct a query that will do this?  I also need to be able to check 
>> >multiple boxes on the form and return records that have a "yes" for all those 
>> >boxes, but also not exclude any records that may have additional fields that 
>> >contain a "yes".
>> 
>> If you insist on using this flawed, wide-flat design, then you'll need a
>> criterion on each field of
>> 
>> =Forms!yourform!Attribute3 OR Forms!yourform!Attribute3 = False
>> 
>> The query grid will get REALLY REALLY UGLY (with as many calculated fields as
>> you have checkboxes, and many, many OR lines).
>> 
>> A normalized design will have three tables to model the many to many
>> relationship. Let's say you have a table Entities, a table Attributes (with
>> one record for each of your AttributeN fields), and a tall thin table
>> EntityAttributes with fields EntityID, AttributeNo, and AttributeValue (a
>> yes/no field) - or you could simply take the existance or nonexistance of a
>> record as the value. Your query then becomes trivial - find all records in
>> EntityAttributes with the desired AttributeNo values.
>> -- 
>>              John W. Vinson [MVP]
>> 
0
Peter
2/27/2008 5:09:10 PM
On Wed, 27 Feb 2008 06:21:02 -0800, Jake <Jake@discussions.microsoft.com>
wrote:

>Thanks for the reply.  I did not set up this table the way it is.  It is 
>Medicare member information given to us by the government.  There are 
>actually 75 different "attribute" fields, and just over 60,000 records.  Is 
>there any efficient way to take the information from this table and construct 
>tables as you have described?

Yes, a Normalizing Union Query. The details would depend on the actual
structure of your table. Could you post the names and datatypes of the
non-attribute fields and a couple of representative fieldnames? The query
isn't that hard to set up but I hesitate to give an example while I'm in the
dark about your actual structure.
-- 
             John W. Vinson [MVP]
0
John
2/27/2008 5:52:31 PM
Thanks again for the reply and your offer of help.  We have decided to go in 
a different direction for searching/analyzing this data which is not ideal, 
but will work O.K. 

"John W. Vinson" wrote:

> On Wed, 27 Feb 2008 06:21:02 -0800, Jake <Jake@discussions.microsoft.com>
> wrote:
> 
> >Thanks for the reply.  I did not set up this table the way it is.  It is 
> >Medicare member information given to us by the government.  There are 
> >actually 75 different "attribute" fields, and just over 60,000 records.  Is 
> >there any efficient way to take the information from this table and construct 
> >tables as you have described?
> 
> Yes, a Normalizing Union Query. The details would depend on the actual
> structure of your table. Could you post the names and datatypes of the
> non-attribute fields and a couple of representative fieldnames? The query
> isn't that hard to set up but I hesitate to give an example while I'm in the
> dark about your actual structure.
> -- 
>              John W. Vinson [MVP]
> 
0
Utf
2/27/2008 8:12:02 PM
On Wed, 27 Feb 2008 12:12:02 -0800, Jake <Jake@discussions.microsoft.com>
wrote:

>Thanks again for the reply and your offer of help.  We have decided to go in 
>a different direction for searching/analyzing this data which is not ideal, 
>but will work O.K. 

Cool. Sometimes you have to choose your battles...
-- 
             John W. Vinson [MVP]
0
John
2/27/2008 10:15:10 PM
Reply:

Similar Artilces:

Timer for Queries?
Does anyone know of a macro or add-on that I could use as a simple timer for queries? I don't like to use the CPU time in the Task Manager because of it's inaccuracy when not receiving full CPU usage. THanks for any suggestions -- cmungs Exactly what are you trying to accomplish? Are you trying to cause a query to run automatically every so often? If so, you will need to use the timer event on a form to do that. -- Lynn Trapp Microsoft MVP (Access) www.ltcomputerdesigns.com "cmungs" <cmungs@discussions.microsoft.com> wrote in message news:88EC7019-045F-4EF...

Outlook Forms slow to load
All of the suddent, one of my customers is having an issue with his outlook client. His forms are taking 3 minutes to load. Any idea why this may be happening? Where are the forms he's trying to load? They wouldn't be halfway around the world, would they? -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "Boomer" <marionFSU@gmail.com> wrote in message news:1171297633.827243.132230@h3g2000cwc.googlegroups.com... > All of the suddent, one of my customers is having an issue with his > outlook client. His forms are ta...

Erratic results from query criteria
I am getting different results from running the same query with the same selections. One moment it is all behaving as expected, the next it has gone haywire. (I have done what appears to me to be EXACTLY what I have done in another database, where it works perfectly every single time.) In a query I have, amongst others, the following fields: Category SubCategory Company I want to be able to select any OR ALL of the relevant fields. I have the following criteria: Like "*"&[Type Category otherwise leave blank for ALL]&"*" Like "*"&a...

The disappearing form
In using Access 2007, I have a database with five joined tables. I want to make a form, based on the "main table" and then four individual subforms. This works fine for the first of the four subforms, but when I add the second in design view, and then look at my handy work in Form View, all I have is a blank, white display, none of the controls are visible. This is the most complex form I have ever attempted and can not determine what is wrong. Please help. Paul If your form is blank, that generally means there was no data there to show. Make sure your control sour...

Excel Forms #5
Once I have created a form (for entering data in a spreadsheet)...is there a way to save the form for future use to avoid having to choose the columns each time I want to enter data? If you referring to Excel's Data, Form feature if you assign the name "database" to the list you do not have to select the list to use it with Data, Form. -- Jim "wheresleo" <wheresleo@discussions.microsoft.com> wrote in message news:FA4C1EF6-FF2D-4EE3-837D-22814D6A9F34@microsoft.com... | Once I have created a form (for entering data in a spreadsheet)...is there a | way to sa...

Update Query ?
Is there a way to 1) Assign events when adding in data thru an update query for example if you append a bunch of data into a table could you then do some kind of an update query to say if there is an initial event and no others tag this one Renewal 1 etc.. the only real data you have to go on would be Customer A and the total amt .. the event, renewal event and the delta would all need to be added in example: Say Customer A comes in with an initial deal then Customer A renews their deal So, the data would look like when you're done.: Year Custo...

A phantom blank form opens with my form
I have a form that is used for data entry. When it opens there is a phantom blank rectangle that opens adjacent to the regular data entry form. The form is opened via VBA. I have the form set to data entry with additions set to yes. Once I enter data it dissapears. At other times it locks up everything where I have to use the task manager to close. What the . . . First thing I would do would be to see if there are updated Graphics drivers for my hardware. -- HTH, George "Programming Artist" <Programming Artist@discussions.microsoft.com> wrote in message news:2703E1...

design query match anywhere?
In the design query I want to match the letters "ABC" anywhere in the column 'description'. I could not get instr to work by using: InStr(description, "ABC")) > 0 How else can I match ABC (upper and lowercase) to anywhere in my 'description' column? Thanks! Are you saying you put that InStr bit as a criteria under your Description field in the query designer? Try putting Like "*ABC*" as the criteria instead. Alternatively, you could add a computed field to the query InStr([Description, "ABC") and then put >0 as the ...

Unexpected Error- Running Advance Find Query
I am getting a message that says "Unexpected Error An Error has occurred" when I am running an advanced find query on two custom entities. It seems to be when I have certain custom fields included in my view that the query errors out. Any help on this would be greatly appreciated. Thanks so much. Just wanted to add that I seem to get errors when there is a 0.00 amount in these fields... "TJ" wrote: > I am getting a message that says "Unexpected Error An Error has occurred" > when I am running an advanced find query on two custom entities. It se...

recordset "over" 2 forms
I think this is a rather basic question and difficult to explain, but I'll try I have this form with 1 entryfield and 1 puhbutton In this entryfield I enter a name, or part of a name I click the pushbutton and another form opens, based upon what I entered in the first form The code for the pushbutton of the first form is: Private Sub Knop13_Click() If IsNull(Me!Naam_lk) = False Then If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then End If End If If IsNull(Me!Naam_lk) = False Then Dim g As Form, f As Form Dim db As Database Set db = Cur...

pass through query
If a combobox is populated by a pass-through query, does it requery every time the form is closed and reopened? Thanks, Sam Yes. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County Sam wrote: > If a combobox is populated by a pass-through query, does it requery every > time the form is closed and reopened? > Thanks, > Sam ...

Transparent form with hourglass?
I want to have a maximized form that is transparent. In the center is a label with some text. I could not figure out how to have a waitcursor displayed on the form. Does anyone know how to do that with a transparent form? As an alternative, I tried setting the opacity to something low like 5%. The waitcursor worked but I could not see the label text in the middle of the form. Thanks for any help you can provide. ...

a count field in a query?
Hello, I have a query in which I would like to create a field which increments by 1 for each record selected, so if there are 10 records selected by the query, this column would show numbers 1 to 10. Ideally I would like to have some text in front of each number, say invoice1, invoice2 etc. From a previous posting I realise that this is frowned upon but it would be the simplest solution for my problem! How can I do this? Thanks Geoff On Mon, 03 Dec 2007 08:54:00 +0000, Geoff Cox <<>> wrote: >Hello, > >I have a query in which I would like to create a field which >...

Multiple criteria
Ok I have a workbook I am working on for someone else and my formulas will not work. Any help would greatly be appreciated. =SUMPRODUCT(--(C4:C59>=5900),--(C4:C59<=5999)) this works like a charm but I need to use this plus (e4:e59="g-shift"). I need the first formula to be the condition to count the second formula. so basically i want if c4 has 5950 and E4 has g-shift then I get 1 and if e4 is blank then i get 0. Everything I have tried says that the formula is wrong. Did you try: =SUMPRODUCT(--(C4:C59>=5900),--(C4:C59<=5999),--(e4:e59="g-shift")) I...

Saving Username and Pass with Web Queries
I am pulling data from a website that requires you to provide a usernam and password everytime you visit the site. Excel has cachin capabilities, but everytime you close excel and try and open up th spreadsheet again, it can't login. What is the fix for this? Thanks, Hend -- Message posted from http://www.ExcelForum.com Bump! --- Message posted from http://www.ExcelForum.com/ ...

Birthday query for many children in one record
I have a database for the church, it has one main flat table only. Each record for the parents have field for child1 name, child1birthday, child2 name, child2birthday, child3 name, child3birthday - up to 5 children. I am having difficulty trying to get a report to list the birthdays of the children like this parent name, child 1 name, child 1 birthday month etc. so you get something like this:- Parent John Smith, child Mary Smith January 3 Parent Fred Jones, child Bert Jones March 4 Parent John Smith, child Jane Smith March 6 Parent Harry Brown, child Jane Brown March 6 Parent Bert Taylor,...

Form Not Opening Right
I am using the following code from to open a form from another continuous form. DoCmd.OpenForm "frmDhallAddExpiredRefRecy", , , , acFormAdd, , [DHallID] = Me.DHallID However, the form opens except that the DhallID does not transfer. Does anyone know what I am doing wrong? The DhallID is an autonumber field. -- Thanks As Always Rip Ripper wrote: > I am using the following code from to open a form from another continuous > form. > DoCmd.OpenForm "frmDhallAddExpiredRefRecy", , , , acFormAdd, , [DHallID] > = Me.DHallID >...

Unresponsive Query Wizard
Hi there, I have an Excel 2003 user who is using a spreadsheet that pulls data from our SQL server. When he opens it and refreshes the data it is fine, it pulls the current data, but when he tries to edit the query, the Query Wizard does not appear, he can see it on the task bar, but when he switches focus using task manager everything is greyed out and nothing works. I have tested the file from my computer and it is fine, which suggests a problem with his machine or installation. Does anyone have any ideas? Cheers, Steve Dooza wrote: > Hi there, > I have an Excel 2003 user who...

Another simple query
Dear all, I have a table that contains first names and last names in different fields. Is there any way to write a query that will give as a result the first name and last name in the same field? I hope this makes sense. Thanks in advance! SELECT [last_name_field] & ", " & [first_name_field] AS whole_name FROM [your_name_table] Change the field and table names to whatever your actual fields and tables are. Cheers, Jason Lepack On Apr 23, 9:47 am, Homer <peter.a.r...@googlemail.com> wrote: > Dear all, > > I have a table that contains first names an...

Passing data from one form to another
Hello I have a form called frmMaindB and it has 5 text boxes on it (txtEmployeeTime, txtDTRegular, txtDTReason1, txtDTReason2, txtDTMaintenance) when I double click on the text box it opens up a pop up form named frm_DecimalConversion. On this form I have two text boxes one box I enter data into and the other calculates or converts the data to a decimal. The box that converts the data is called txtDecimal. Then I have a close button which I want to use to close the pop up form and insert the data into the text box I double clicked in to get the pop up or (frm_DecimalConversion). I have r...

Query query
I am trying to create a new field in which it shows the sum total of 10 fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest way to do this? -- Joe NewFieldName: [Charge Time] + [Charge Time 2] + [Charge Time 3] .... etc -- Good Luck BS"D "joet5402" wrote: > I am trying to create a new field in which it shows the sum total of 10 > fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest > way to do this? > -- > Joe I tried this, and it doesn't work. Is there something I'm forgetting? -- Joe ...

Form and SubForm Problem
I have a table tblPhones with a PDkey as the Primary Key. I have another table tblPB with four fields as follows: DDID as the Primary Key PDkey, a lookup field to tblPhones. DirectoryID, a lookup field to a table tblDirectory DeptID, a lookup field to a table tblDepartment The Main Form uses tblPhones as it's record source The Sub Form has tblPB as it's record source Link Child Fields = PDkey Link Master Fields = PDkey I can create a new record in tblPhones from the Main Form, WITHOUT entering data in the SubForm. How do I make sure data is entered into the SubForm when adding a n...

group by query trouble
I'm trying to run a query that counts the number of people with hemoglobin of type SS, type SC, and then all others. There are about 12 different kinds of types. Basically I want a count for SS, a count for SC, and then a count that totals all the others into one count. Hopefully that makes sense. I'm using group by for the SS and SC which works great, but I'm not sure how to tell it to add up the others. I'm not a big fan of nested IIf statements, but this should work after you put in the proper field and table names: SELECT IIf([Hemoglobin]="SC","SC&...

To Query or not to Query??
Hello all - I'm a newbe to Access but have made great progress. I'm using Acess 2003. The db is up and running prefectly. Now I need to tackle the reporting. I have seen posts about reports and queries and am a little confused. Do I need to create a query to run my reports off of? I have a tabbed subform in the main form. There are seven tabs breaking up all the services we provide. Like "Promo Items", "Leads", "Client Printed Material","Internal Print Material" and so on. The main form has the User, Branch and Marketing Rep. I need to...

Workbook does not Save from User Form
I pasted this code in my User Form to assign the Name & Save a Workbook as varibles from different Text Boxes. For some reason it assigns the name correctly, but when you click on the save in the Save As Dialog box, only the Error Message pops up and the Workbookbook does not save. What am I missing? 'Save Engineering Spec 11 Control Button Private Sub Save_Eng_Spec_11_Click() Dim strFile As String Dim bk As Workbook strFile = "SPEC " & TEO_No_1.Value _ & Space(1) & CLLI_Code_1.Value _ & Space(1) & CES_No...