Solved

Access 2007 How do you add a checkbox in query

Posted on 2011-02-28
3
615 Views
Last Modified: 2012-05-11
I need to add a  new Yes\no box in a make table query with a value 0.  How do I do that?
0
Comment
Question by:glomo82
  • 2
3 Comments
 
LVL 5

Expert Comment

by:kpltechgroup
ID: 35003786
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35003843
you can't do that in a make table query.
after running your make table query (without the yesNo field), run this codes



sub addYesNoField()
Dim p As DAO.Property, db As DAO.Database
Set db = CurrentDb
With db.TableDefs("tableX")
    .Fields.Append .CreateField("MyYesNo", dbBoolean)
    Set p = .Fields("MyYesNo").CreateProperty("displaycontrol", dbInteger, 106)
    .Fields("MyYesNo").Properties.Append p
End With
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 35003859

this sub will create the yesno field as check box


sub addYesNoField()
Dim p As DAO.Property, db As DAO.Database
Set db = CurrentDb
With db.TableDefs("tableX")
    .Fields.Append .CreateField("MyYesNo", dbBoolean)
    Set p = .Fields("MyYesNo").CreateProperty("displaycontrol", dbInteger, 106)
    .Fields("MyYesNo").Properties.Append p
End With
end sub


change tablex and MyYesNo feild with actual names


0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

820 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