B
BruceM
I have been experimenting with Allen Browne's system for using an Integer
field in place of a Yes/No field:
http://allenbrowne.com/NoYesNo.html
The article contains the following code as a way of getting a table to use a
check box as a display control for an Integer field:
CurrentDb.TableDefs("Table1").Fields("Field1").Properties("DisplayControl")
= CInt(acCheckBox)
Allen makes a sample database available. It contains only a table with two
fields: one for Yes/No and the other for Yes/No/Null. The Yes/No field
shows the display control on the lookup tab as 106, which is for check box,
as I understand. I can copy that field into a table in my database, rename
it, and all is well. However, if I try in my own database to select 106 as
the display control it does not work, of course. Since there are no other
objects in the sample database file I couldn't see where the code is used.
I finally figured out that I can copy the code above into a sub in a
standard module (substituting an actual table and field name) and run the
code. The named field will have 106 as the display control, and will
display in datasheet view as a checkbox. I can then copy and paste that
field, just as I can copy and paste the field from Allen sample table.
However, I cannot enter 106 as the display property for other number fields
in my database. It seems likely that Allen used a table from an existing
database in which he used the TableDefs code, and stripped out everything
except one table with two fields. Somehow the changed field has acquired
properties that persist even in another database. The custom field is
completely portable.
What's going on? How did the field transformed by code acquire properties
unavailable to other fields? Other than "106" as the display control I
cannot find a property or anything else to explain that the field is
different from other number fields.
field in place of a Yes/No field:
http://allenbrowne.com/NoYesNo.html
The article contains the following code as a way of getting a table to use a
check box as a display control for an Integer field:
CurrentDb.TableDefs("Table1").Fields("Field1").Properties("DisplayControl")
= CInt(acCheckBox)
Allen makes a sample database available. It contains only a table with two
fields: one for Yes/No and the other for Yes/No/Null. The Yes/No field
shows the display control on the lookup tab as 106, which is for check box,
as I understand. I can copy that field into a table in my database, rename
it, and all is well. However, if I try in my own database to select 106 as
the display control it does not work, of course. Since there are no other
objects in the sample database file I couldn't see where the code is used.
I finally figured out that I can copy the code above into a sub in a
standard module (substituting an actual table and field name) and run the
code. The named field will have 106 as the display control, and will
display in datasheet view as a checkbox. I can then copy and paste that
field, just as I can copy and paste the field from Allen sample table.
However, I cannot enter 106 as the display property for other number fields
in my database. It seems likely that Allen used a table from an existing
database in which he used the TableDefs code, and stripped out everything
except one table with two fields. Somehow the changed field has acquired
properties that persist even in another database. The custom field is
completely portable.
What's going on? How did the field transformed by code acquire properties
unavailable to other fields? Other than "106" as the display control I
cannot find a property or anything else to explain that the field is
different from other number fields.