changing a boolean field DisplayControl to acCheckBox won't work (1 Viewer)

smig

Registered User.
Local time
Today, 07:55
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:

Ranman256

Well-known member
Local time
Today, 00:55
Joined
Apr 9, 2015
Messages
4,337
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)
 

smig

Registered User.
Local time
Today, 07:55
Joined
Nov 25, 2009
Messages
2,209
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.
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Jan 23, 2006
Messages
15,379
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.
 

smig

Registered User.
Local time
Today, 07:55
Joined
Nov 25, 2009
Messages
2,209
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
 

smig

Registered User.
Local time
Today, 07:55
Joined
Nov 25, 2009
Messages
2,209
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Jan 23, 2006
Messages
15,379
Here is another link. It references combobox and textbox, but my guess is other control types could work.
 

smig

Registered User.
Local time
Today, 07:55
Joined
Nov 25, 2009
Messages
2,209
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 :)
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Jan 23, 2006
Messages
15,379
No problem, I hadn't heard of DisplayControl.
 

Users who are viewing this thread

Top Bottom