changing a boolean field DisplayControl to acCheckBox won't work

smig

Registered User.
Local time
Today, 04:42
Joined
Nov 25, 2009
Messages
2,209
I'm trying to change the DisplayControl of a boolean (YesNo) field to acCheckBox, with no success :banghead:

here is a piece of my code
Code:
boo = False
For i = 0 To DataDB.TableDefs("MyTable").Fields("MyYesNoField").Properties.Count - 1
    If DataDB.TableDefs("MyTable").Fields("MyYesNoField").Properties(i).Name = "DisplayControl" Then
        boo = True
    End If
Next i
If boo = False Then         ' -- Append the "DisplayControl" property to field if not already exist
    Set newPrp = DataDB.TableDefs("MyTable").Fields("MyYesNoField").CreateProperty("DisplayControl", dbInteger, acCheckBox)
    DataDB.TableDefs("MyTable").Fields("MyYesNoField").Properties.Append newPrp
End If
DataDB.TableDefs("MyTable").Fields("MyYesNoField").Properties("DisplayControl").Value = acCheckBox
I tried both acCheckBox and 106 with the same result.
I have no problem, using similar code changing the field's other properties like Format, Description, Required and DefaultValue, but DisplayControl will not be changed and stay as TextBox
*** The field has a "True/False" Format.
I can manually change it if I go into the BE db.
:banghead::banghead::banghead:

Thanks
Tal
 
Last edited:
You don't have to alter anything. You don't need code.
Set the checkbox to the field and the field is yes/no (Boolean)
 
You don't have to alter anything. You don't need code.
Set the checkbox to the field and the field is yes/no (Boolean)

I know how to do it manually.
I want it to be done by code on remote machine.
 
smig,

I may be misunderstanding something but I think you are trying to change a Control on a form.
It isn't the field in the table, it's the control on the Form you want to create/make as a checkbox.

I don't see any materials that would change how a table "field" bound to a control can be changed using a table field property setting????

Here is the reference I looked at
https://msdn.microsoft.com/en-us/library/bb243056(v=office.12).aspx

Sorry if I'm missing something obvious.
 
You misunderstand 😊
This routine will change a field property. Try it for Description. For unknown reason i cant make it work for the DisplayControl property 😁

Sent from my m2 note using Tapatalk
 
I saw this link. Not helping.
Yes, you must make sure a property exist, or add it, before changing it. This part I do.

As i said i can set all other properties, but not the DisplayControl for the YesNo field.

Sent from my m2 note using Tapatalk
 
Here is another link. It references combobox and textbox, but my guess is other control types could work.
 
Thanks,

If the field Type is YesNo the DisplayControl can be chaned to CheckBox or ComboBox.
For all other field types only TextBox is available.

For some reason it won't change the FieldType property though I can change all other properties :mad:
As the end user will never go into tables and I will rarely do it too I give up with this.

Thanks again for your time :)
 
No problem, I hadn't heard of DisplayControl.
 

Users who are viewing this thread

Back
Top Bottom