Solved

MS Access Add A Yes/No Box to Each Record

Posted on 2016-10-03
5
53 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
5 Comments
 
LVL 36

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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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 45

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 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 41829572
glad I could help.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

828 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