 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: ADOX Table Creation - Access Properties Archived to Disk
I modified the original post...
Private Sub ChangeWidth()
On Error Resume Next
Dim dbs As DAO.Database
Set dbs = CurrentDb
' Index is the table name, fields("Name") change for whatever field needed
dbs.TableDefs("Index").Fields("Name").Properties("ColumnWidth").Value = 5000
' Sometimes caused errors without the following
dbs.TableDefs("Index").CreateProperty "RowHeight", dbInteger, 5
dbs.TableDefs("Index").Properties("RowHeight").Value = 5000
Set dbs = Nothing
End Sub
[Edited by JLRodgers on 11-06-2002 at 05:15 PM GMT]
|
|
11-06-2002 at 09:42 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: ADOX Table Creation - Access Properties Archived to Disk
Not sure offhand, if you have Access, you can search in the help (vb editor within access [maybe in the MSDN library too]) for:
RowHeight
ColumnWidth
In the OfficeXP versions there's a link for "Visual Basic" code, that has lists for the DAO and ADO code.
|
|
12-06-2002 at 02:25 AM |
|
|
ezimmerman Level: Guest

|
Re: ADOX Table Creation - Access Properties Archived to Disk
I haven't found the ADO code equivalent yet, but I think it has something to do with the ADO command object...
Ok, the original code that was submitted didn't work quite right, but this is a functional, slightly modified copy.
I am modifying all widths of the fields in the table based on their field name.
On error resume next is bad... use explicit err numbers for resume nexts...
g_fn() is an global array of strings. (filenames)
Private Sub ChangeListWidth(ByVal mode As Integer)
On Error GoTo errHandler
Dim dbs As DAO.Database
Dim prpNew As DAO.Property
Dim strDest$, str_field$
Dim i%, fieldwidth%
Set dbs = DBEngine.OpenDatabase(g_fn(rDEST)) 'CurrentDb
Select Case mode
Case rGPLUS: strDest = "Lists"
Case rVGPLUS: strDest = "ListsVG+"
Case Else
End Select
DoEvents
For i = 0 To dbs.TableDefs(strDest).Fields.Count - 1
DoEvents
str_field = dbs.TableDefs(strDest).Fields(i).Name
If (str_field = "ID") Then
ElseIf (InStr(1, str_field, " Val")) Then
fieldwidth = 300
Else
fieldwidth = 1500
End If
Set prpNew = dbs.CreateProperty("ColumnWidth", dbInteger, 5)
dbs.TableDefs(strDest).Fields(i).Properties.Append prpNew
dbs.TableDefs(strDest).Fields(i).Properties("ColumnWidth").Value = fieldwidth
Next i
Set dbs = Nothing
Exit Sub
errHandler:
Select Case Err.Number
Case 3367 'already exists in collection
Resume Next
Case Else
MsgBox Err.Number & " " & Err.Source & Chr(13) & Err.Description, vbCritical
End Select
End Sub
eRiC
|
|
13-06-2002 at 01:30 PM |
|
|  |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: ADOX Table Creation - Access Properties Archived to Disk
The reason for the "resume next" was that the only line that could've caused a problem was the "create property" in the example. That property should already exist, but for some reason it didn't always like running without it. In the event there was another error in the code, then there would've been a problem with the DAO engine, and chances are, you'd never get to run the code anyway.
|
|
13-06-2002 at 06:45 PM |
|
|
|
|
 |
 |