Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox data in a table

Status
Not open for further replies.

Aietoe

Technical User
Nov 30, 2000
85
CA
Hi!

I created a table with a column that has a type of control "CheckBox" and a format "YesNo".

I want to add that information in an other table.

When i execute the query(Creation),

SELECT [xxxxxxx].YesNo INTO aaaaaaaaa
FROM [xxxxxxx]
;

the type of control in my new table is changed to "text zone".

What am i doing wrong?

Thanks
 
I think this might help you out...

SQL does have a cBool function (Convert to Boolean)

Try:
Code:
SELECT cBool([xxxxxxx].[YesNo])
   INTO aaaaaaaaa
   FROM [xxxxxxx] ;


Hope that helps.

-MoGryph
[8O)
 
Unfortunatly, this doesn't work.
Thanks a lot anyway MoGryph.

Aietoe
 
Sorry 'bout that.

I tried it myself and came up with the same confusion, err, conclusion.

Here's what I did, to get it to work:
Create 2 functions:
Code:
Function UpdateDisplayControl()
    Dim DB As Database
    Dim TBD As TableDef
    Dim fld As Field
    Dim prp As Property
    
    Set DB = CurrentDb
    Set TBD = DB.TableDefs("NewTable")
    Set fld = TBD.Fields("YesNo")
    If HasProperty(fld, "DisplayControl") Then fld.Properties.Delete ("DisplayControl")
    Set prp = fld.CreateProperty("DisplayControl", dbInteger, "106")
    fld.Properties.Append prp
    DB.TableDefs.Refresh
    
End Function

Function HasProperty(obj As Object, prpName As String) As Boolean
    Dim prp As Property
    HasProperty = False
    For Each prp In obj.Properties
        If prp.Name = prpName Then HasProperty = True
    Next
End Function
substitute "NewTable" and "YesNo" with the names of the table you're creating, and the name of the field that needs to be a "YesNo" checkbox.

Then, create a Macro
The macro should contain:
SetWarnings (property WarningsOn: No)
OpenQuery (property QueryName: the name of your create query)
RunCode (Property FunctionName: =UpdateDisplayControl() )
SetWarnings (property WarningsOn: Yes)

This, for certain, will take care of it.

-MoGryph
[8O)
 

I suggest that you create the table first with the correct column data types and then run an append query to add rows to the table rather than using a Make table query. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
I finaly use tlbroadbent's solution that is quite simple and works well to answer my needs.

Thanks to both of you MoGryph and tlbroadbent.


Aietoe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top