Table column width

D

Dexter

hi!

In MS Access default table view to columns can set width.
here is the function where i give table name,Column name and width and i
need to check is there a table with name like sName,column like sColName and
is width for this column is like sWidth! Function likes ok,but the field
property 20-FieldWidth always returns value= -1.

Function IsColumnWidth(ByVal sName As String, ByVal sColName As String,
ByVal sWidth As String) As Boolean
For Each tabula As dao.TableDef In ACS.TableDefs
If tabula.Name.ToUpper.Trim = sName.ToUpper.Trim Then
For Each lauks As dao.Field In tabula.Fields
If lauks.Name.ToUpper.Trim = sColName.ToUpper.Trim Then

Dim platums As Decimal = CDec(sWidth)
Dim maxw = platums + platums * 0.1
Dim minw As Decimal = platums - platums * 0.1
If lauks.Properties.Item(20).Value > minw AndAlso
lauks.Properties.Item(20).Value < maxw Then
Return True
End If
End If
Next
End If
Next
Return False
End Function


I hope to get your answers soon!

Dexter
 
D

Douglas J. Steele

From the Help file:

In Visual Basic, the ColumnWidth property setting is an Integer value that
represents the column width in twips. You can specify a width or use one of
the following predefined settings.

Setting Description
0 Hides the column.
-1 (Default) Sizes the column to the default width.
 
D

Dexter

If i change the table column width in program code i get value= 930 {short}!
how i can get it to same type like in access?
 
P

Pieter Wijnen

You can convert by using the following API

Private Const WU_LOGPIXELSX = 88
Private Const WU_LOGPIXELSY = 90

Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal
iCapability As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal
hDC As Long) As Long

Public Function TwipsToPixels(nTwips As Long, nDirection As
thLogPixelsDirection) As Long

Const nTwipsPerInch = 1440
Dim hDC As Long, nPixelsPerInch As Long
hDC = GetDC(Access.Application.hWndAccessApp)
If (nDirection = 0) Then 'Horizontal
nPixelsPerInch = GetDeviceCaps(hDC, WU_LOGPIXELSX)
Else 'Vertical
nPixelsPerInch = GetDeviceCaps(hDC, WU_LOGPIXELSY)
End If
ReleaseDC 0, hDC
TwipsToPixels = (nTwips / nTwipsPerInch) * nPixelsPerInch
End Function

HtH

Pieter
 

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