Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DisplayControl setting in VBA

477 views
Skip to first unread message

Bill Buchan

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
Any help on this would be much appreciated.

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.


David McTavish

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
Bill,
the Access list box does not have this property. You are confusing it with
the Visual Basic list box. I believe you can insert the VB ActiveX ListBox
control and this will mimic the one you are familiar with.

Regards,
David McTavish

Bill Buchan

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to

David McTavish wrote in message <6q7nfr$m...@news.or.intel.com>...


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.


Paul Shapiro

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to
You need to create the property. Some of the Access-specific properties are
only created when you enter a value through the user interface. I use the
function below to set properties. You would call it as:
fSuccess = pjsSetObjectProperty(MyObject:=fldNew,
strPropertyName:="DisplayControl", _
intPropertyType:=dbInteger, varPropertyValue:=acCheckBox). Note that the
DisplayControl property is an integer, and Access defines a constant for
setting it to be a check box.

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>...

Terry Kreft

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to
The allowed values for the DisplayControl properties for a Yes/No field are
acCheckBox (106), actextBox (109) and acComboBox (111).

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>...

0 new messages