 |
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

January 25th, 2005, 09:15 PM
|
Registered User
|
|
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ADOX: Changing the view of a boolean
I'm creating a table with adox, and having several columns set to boolean.
I do this in the creation-phase before I Append the column.
col.Type = adBoolean
However. If I open the table, the boolean-columns does not show as a check-box as I want them to... :(
They simply just show as a text-field as if it was any other type of field.
How do I change the view to checkbox rather than textfield???
Thanks
Thomas
|

January 25th, 2005, 11:01 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Thomas,
I have a hunch that this might be one of those obscure cases illustrating the point that DAO and Jet were made for each other, ADO/ADOX and Jet weren't. You can add the checkbox to your Boolean field display in DAO using the CreateProperty method of the Field object. The ADO Field object doesn't support a CreateProperty method. In DAO, iterate through your TableDef's Fields collection adding the CheckBox display control like this:
For Each fld In tdf.Fields
If fld.Type = dbBoolean Then
Set prp = fld.CreateProperty("DisplayControl", dbLong, 106)
fld.Properties.Append prp
End If
Next fld
HTH,
Bob
|

May 31st, 2006, 07:16 PM
|
Registered User
|
|
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Bob Bedell
thanks for the POST, I was looking for this as well.
however, dbLong is wrong type for this to work.
here full code that is working:
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim prp As DAO.Property
Dim sDbPath$
Dim sDbPassword$
Dim sTableName$
sDbPath$ = "c:\vAdoDb.mdb" 'this is coming from my complete OCX Library for Access 2000
sDbPassword$ = ""
sTableName$ = "tbl_Test"
Set dbs = OpenDatabase(sDbPath$, False, False, "MS Access;PWD=" & sDbPassword$ & ";")
Set tdf = dbs.TableDefs(sTableName$)
For Each fld In tdf.Fields
If fld.Type = dbBoolean Then
Set prp = fld.CreateProperty("DisplayControl", dbInteger, 106)
fld.Properties.Append prp
Set prp = fld.CreateProperty("Format", dbText, "Yes/No")
fld.Properties.Append prp
' more property you can mess with
' Set prp3 = fld.CreateProperty("ColumnWidth", dbInteger, -1)
' Set prp4 = fld.CreateProperty("ColumnOrder", dbInteger, 0)
' Set prp5 = fld.CreateProperty("ColumnHidden", dbBoolean, False)
End If
Next fld
dbs.Close
Set dbs = Nothing
Set tdf = Nothing
Set fld = Nothing
Set prp = Nothing
|

January 6th, 2007, 07:02 AM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks to the post above and a bit of tinkering, I managed to get checkboxes into my ADO created Access database. However, I did have to alter things slightly to get it to work in Visual Basic 2005. This code runs after I've pulled in the data into the created Access MDB using ADO and then closed the connection.
I also added another 'For Each' statement to loop through each table in the database after going through each table's specific set of fields.
Here's the code:
Dim dbs As dao.Database
Dim tdf As dao.TableDef
Dim fld As dao.Field
Dim prp As dao.Property
Dim dbe As New dao.DBEngine
Dim sDbPath$
Dim sDbPassword$
sDbPath$ = "C:\YourDatabase.mdb" 'this is coming from my complete OCX Library for Access 2000
sDbPassword$ = ""
dbs = dbe.OpenDatabase(sDbPath$, False, False, "MS Access;PWD=" & sDbPassword$ & ";")
For Each tdf In dbs.TableDefs
For Each fld In tdf.Fields
If fld.Type = dao.DataTypeEnum.dbBoolean Then
prp = fld.CreateProperty("DisplayControl", dao.DataTypeEnum.dbInteger, 106)
fld.Properties.Append(prp)
prp = fld.CreateProperty("Format", dao.DataTypeEnum.dbText, "Yes/No")
fld.Properties.Append(prp)
' more property you can mess with
' Set prp3 = fld.CreateProperty("ColumnWidth", dbInteger, -1)
' Set prp4 = fld.CreateProperty("ColumnOrder", dbInteger, 0)
' Set prp5 = fld.CreateProperty("ColumnHidden", dbBoolean, False)
End If
Next fld
Next tdf
dbs.Close()
dbs = Nothing
tdf = Nothing
fld = Nothing
prp = Nothing
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
ADOX |
speedlearner |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 |
1 |
June 23rd, 2006 04:15 PM |
Create a Table using ADOX |
JDrown |
Access VBA |
7 |
April 12th, 2006 03:52 AM |
ADOX problem |
toshesh |
VB Databases Basics |
1 |
December 23rd, 2005 10:34 AM |
ADOX/MDAC Problem |
r4ross |
Access VBA |
2 |
December 2nd, 2005 10:39 AM |
Dynamic queries without ADOX |
gpet |
Access |
0 |
June 10th, 2005 01:33 AM |
|
 |