How do I set the DisplayControl property in VBA? I want to make my yes/no
columns appear as check boxes.
I'm trying things like:
fld.Properties("DisplayControl") = "Check Box"
where fld is the Field I am trying to change.
However Access (A97) merely complains that the property is not found.
Many thanks,
- Bill.
Regards,
David McTavish
I'm not sure where the list box comes in. Maybe my question was ambiguous -
I'll try to clarify! I am trying to change the property associated with
each field in the Table view. In the design view for the table, the Data
Type is "Yes/No", and under the Lookup Tab, the Display Control field says
"Text Box" or "Check Box" or "Combo Box". I can change this manually using
the combo box on this field. What I'd really like to be able to do is, in
code, set this to be "Check Box". Is this possible?
Thanks,
- Bill.
Public Function pjsSetObjectProperty(MyObject As Object, strPropertyName As
String, _
intPropertyType As Integer, varPropertyValue As Variant) As Boolean
'Purpose: Set field properties which may or may not already exist, like
Description
'Written: PJS 6/13/95
On Local Error GoTo Error_Handler
Dim MyProperty As DAO.Property
If Not (IsEmpty(varPropertyValue) Or IsNull(varPropertyValue) Or _
IsMissing(varPropertyValue)) Then
MyObject.Properties(strPropertyName) = varPropertyValue
End If
pjsSetObjectProperty = True
Exit_Handler:
On Error Resume Next
Set MyProperty = Nothing
Exit Function
Error_Handler:
Select Case Err.Number
Case 3270 'Property does not exist
'Create Property object, setting its Name, Type, and Value
properties.
Set MyProperty = MyObject.CreateProperty(strPropertyName,
intPropertyType, varPropertyValue)
MyObject.Properties.Append MyProperty
MyObject.Properties.Refresh
Resume Next
Case Else
Set objError = New pjsError
objError.pjsErrorCode Procedure:="pjsSetObjectProperty",
ModuleName:=mconStrModuleName
Set objError = Nothing
pjsSetObjectProperty = False
End Select
Resume Exit_Handler
Resume
End Function
--
Paul Shapiro
paulS...@mindspring.com
Bill Buchan wrote in message <6q7k7t$ijl$1...@phys-ma.sol.co.uk>...
So this code works
Dim lodb As Database
Dim lotab As TableDef
Dim lofld As Field
Dim loprop As Property
Set lodb = CurrentDb
Set lotab = lodb.TableDefs("table1")
Set lofld = lotab.Fields("blnOption")
Set loprop = lofld.Properties("DisplayControl")
loprop.Value = acCheckBox
Bill Buchan wrote in message <6q93c2$2m9$1...@phys-ma.sol.co.uk>...