?
Solved

MS Access Add A Yes/No Box to Each Record

Posted on 2016-10-03
5
Medium Priority
?
70 Views
Last Modified: 2016-10-05
Thank you for looking at my question,

I want to create a table that takes the records from one query and adds a Yes/No box to each record.

I have two queries qryPriceData and qryYesNo and I have tried to combine the two as below but it returns zero records.

SELECT 
qryPriceData.Instrument, 
qryPriceData.Description, 
qryYesNo.YesNo

INTO tblInstrumentSelection

FROM qryPriceData, qryYesNo;

Open in new window


How should I do this please?
0
Comment
Question by:Crxfrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 38

Expert Comment

by:PatHartman
ID: 41826545
Does qryPriceData return records when you run it alone?  Adding the YesNo table as a Cartesian product would not change that.  However there are other ways to add a YesNo column.

1. You can include a dummy field but this won't make it a YesNo data type.  It will be an integer which will work just fine.  In fact I rarely use this data type since most of my data is kept in SQL Server.  You can always bind the field to a checkbox on a form or report to get the visual you want.
SELECT 
qryPriceData.Instrument, 
qryPriceData.Description, 
0 As YesNo

INTO tblInstrumentSelection

FROM qryPriceData;

Open in new window

2. If you prefer to have the additional column defined as Yes/No, then define the temp table and rather than using a make table query, use a delete query and an append query.
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 41826640
I'm guessing that you want the ability to display this information and check the Yes/No either in a continuous form or datasheet, is that correct?

When I want to do this, I have a temp table in my database which contains a numeric ID type field, and a Yes/No field (IsChecked).  I first insert all of the ID field values from the table I want to "tag" with a Yes/No into that table, something like:

INSERT INTO TempYesNo(ID, IsChecked)
SELECT Instrument, 0
FROM qryPriceData

Then I create a query between that table and the other data using that primary key field as the join, allowing me to create an updateable query. that looks something like:

SELECT TempYesNo.IsChecked
, qryPriceData.Instrument
, qryPriceData.Description
FROM qryPriceData INNER JOIN TempYesNo on qryPriceData.Instrument = TempYesNo.ID


HTH
0
 
LVL 46

Expert Comment

by:aikimark
ID: 41826661
I use a make table query to add a boolean field, using the CBool() function in the query to create the Yes/No field.  Be sure to give your new column a name.
0
 

Author Closing Comment

by:Crxfrd
ID: 41829401
Works perfectly, Thank you
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 41829572
glad I could help.
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question