Results 1 to 8 of 8
  1. #1
    bandit is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    3

    Need a query and report that finds "Yes" ticked in @30 Yes/No boxes

    I have a table which has customer details and approximately 30 Yes/No type fields with a vegetable type in each. I need to be able to run a 'query' which will give me the customer name (first name, last name) and which vegetables they have ticked/checked as 'Yes' and ultimately produce a report with this information also



    Probably very simple to many out there but I thank you in advance for your kind help

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    So you're trying to find any record where any vegetable is checked with a yes/no?

    This sounds like a non-normalized table structure but basically you could have a single expression that was something like

    [veg_01] + [veg_02] + [Veg_03]... etc

    Then in your criteria show any record where the value of this sum was less than zero (yes/no fields are stored as a -1 for yes, 0 for no)

  3. #3
    bandit is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    3
    Thanks for your reply. In a nutshell I have a veggiebox business and the customers can opt out of receiving certain veg. Originally I tried to have a relational database with a 'customer details' table and a 'vegetable' table and gave up trying to link them
    So now I have one table with both customer details and vegetables in. So basically I check the yes/no box against whatever the customer has opted out of to record that fact but need to check each week what their optouts are. So I need to pull from the table a list of customers and the vegetables which I have checked as 'Yes'.......sorry hope that makes sense

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    With the data structure you have, this will very difficult. As rpeare pointed out above, your data is not properly normalized. The customer details should contain only one vegetable per record :

    OrderID (which will give you customer ID)
    VegetableID
    ...
    ... plus other fields, like quantity etc.

    Then you need another table for Vegetables:

    VegetableID
    VegetableName
    ...

    Once you do this, reports are easy.

    John

  5. #5
    send2steph is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    6

    I agree with repear.

    Quote Originally Posted by rpeare View Post
    This sounds like a non-normalized table structure...


    So, you want:

    Name Veg1, Veg2, Veg5, Veg10
    Name2 Veg3, Veg8, Veg30
    etc?

    I'm thinking your second column is going to be a bunch of IIf statements in your query.

    IIf(Veg1=-1,"Veg1") & IIf(Veg2=-1,", Veg2") & IIf(Veg3=-1,", Veg3") etc...

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Exactly what John_G said, what you're trying to do is incredibly difficult with a non-normalized structure. How married are you to your current structure?

    What you really should is a structure something like:

    Code:
    tblCustomers
    Cust_ID  Cust_FN  Cust_LN ---> other customer related fields
    
    tblVegetables
    Veg_ID Veg_Name ----> other vegetable related fields
    
    tblCustVeg
    CV_ID Cust_ID  Veg_ID
    The table tblCustVeg is called a junction table because it connects to different tables, in this case connecting your customers to the vegetables they have on their list

  7. #7
    bandit is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    3
    Okay I have created new Tables called
    CustVeg with the fields ContactID (which is a field in my Customers Table) VegID and CustVegID

    and a Table called Veg which has VegID VegName and NotWanted as its fields.

    Could you please advise how these should now be linked relationship wise. ContactID in the Table Customers is an Autonumber but in CustVeg a Number

    I have populated the Veg table with VegName the VegID is an Autonumber

    many thanks

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    your junction table should just include vegetables that the person WANTS not what they want to exclude, it will be easier for you in terms of programming/query building to make it inclusive rather than exclusive. If you build an table where you are tracking the vegetables they DO NOT want you would have to compare it to a list of all your vegetables to get the ones they wanted.

    So if you were going to build a query that showed which vegetables the person wanted to see a list of each week (or month or year)

    You'd add all three tables to your query link the ContactID from your Customer stable to the ContactID in your CustVeg table then link the VEGID from the CustVeg table to the Veg table so you so let's say your CustomerID 1 belonged to John Doe, in your custveg table you had him wanting information on vegetables (VegID's) 1, 3 and 5, in your Veg table you'd Items 1, 3 and 5 corresponded to Peas, Carrots and Corn respectively. Your query would show John Doe on three lines one line for each vegetable he wanted information on.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 01-22-2014, 01:09 PM
  2. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  3. "Send Email" button on Query-Based Report
    By athyeh in forum Programming
    Replies: 5
    Last Post: 07-05-2013, 12:44 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 1
    Last Post: 08-23-2012, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums