How do I know programatically if a table/field has 'Unicode Compression'?

E

Evan Camilleri

How do I know programatically if a table/field has 'Unicode Compression'?

Is there a way to set it programatically via TableDef or Field object?

Evan Camilleri
 
A

Allen Browne

Try:
CurrentDb().TableDefs("MyTable").Fields("MyField").Properties("UnicodeCompression")
 
E

Evan Camilleri

that's what I tried:

Debug.Print fld.Properties("UnicodeCompression")

But I got runtime error 3270, Property not found.

Evan Camilleri
 
A

Allen Browne

Many of these properties are only created when needed, so you may need to
CreateProperty() if you want to set it differently from the default, or just
use error handling to handle the non-existence of the property.

These may be useful:

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

Function SetPropertyDAO(obj As Object, strPropertyName As String, _
intType As Integer, varValue As Variant, Optional strErrMsg As String) As
Boolean
On Error GoTo ErrHandler
'Purpose: Set a property for an object, creating if necessary.
'Arguments: obj = the object whose property should be set.
' strPropertyName = the name of the property to set.
' intType = the type of property (needed for creating)
' varValue = the value to set this property to.
' strErrMsg = string to append any error message to.

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName, intType,
varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & _
" not set to " & varValue & ". Error " & Err.Number & " - " &
Err.Description & vbCrLf
Resume ExitHandler
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top