Solved

MS Access Add A Yes/No Box to Each Record

Posted on 2016-10-03
5
41 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 34

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now