I'm creating a new Access table using ADOX. I can add columns and
indexes, but I'm baffled on how to change field properties. Can
someone give me a hand?
Want to change properties such as: Description (Column property?),
Decimal Places, Caption, Default value, Required indicator, Format,
etc....
TIA,
HexMan
Stripped Code:
Sub CrtTbl1()
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, objTable As
ADOX. Table, objKey As ADOX.Key
Dim col As ADOX.Column
Cn = New ADODB.Connection
Cat = New ADOX.Catalog
objTable = New ADOX.Table
objKey = New ADOX.Key
col = New ADOX.Column
'Open the connection
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\WOMSTR.mdb")
'Open the Catalog
Cat.ActiveConnection = Cn
'Create the table
objTable.Name = "WorkOrder"
'Create and Append a new fields to the "Work Order"
objTable.Columns.Append("WODate", DataTypeEnum.adDate)
objTable.Columns.Append("WOInnInd", DataTypeEnum.adInteger)
objTable.Columns.Append("WOTot", DataTypeEnum.adInteger)
objTable.Columns.Append("WORS1", DataTypeEnum.adVarWChar, 20)
'Create and Append a new primary key
objKey.Name = "PrimaryKey"
objKey.Type = KeyTypeEnum.adKeyPrimary
objKey.Columns.Append("WODate")
objKey.Columns.Append("WOTInnInd")
objTable.Keys.Append(objKey)
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
want to change WODate.format = Short Date
change WODate.caption = "Work Order Date"
change WODate.required = True
want to change WOTot.format = General Number
change WOTot.decimalplaces = 2
change WOTot caption = "Total Qty."
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
'Append the newly created table to the Tables Collection
Cat.Tables.Append(objTable)
' clean up objects
objKey = Nothing
objTable = Nothing
Cat = Nothing
Cn.Close()
Cn = Nothing
End Sub 1 11553
Hi Hexman,
You only need ADOX to create the database, the rest you can do with ADONET
Have a look at this sample, http://www.vb-tips.com/default.aspx?...1-d6dda3c888c8
I hope this helps,
Cor
"Hexman" <He****@Binary.com> schreef in bericht
news:8j********************************@4ax.com... I'm creating a new Access table using ADOX. I can add columns and indexes, but I'm baffled on how to change field properties. Can someone give me a hand?
Want to change properties such as: Description (Column property?), Decimal Places, Caption, Default value, Required indicator, Format, etc....
TIA,
HexMan
Stripped Code:
Sub CrtTbl1()
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, objTable As ADOX. Table, objKey As ADOX.Key Dim col As ADOX.Column
Cn = New ADODB.Connection Cat = New ADOX.Catalog objTable = New ADOX.Table objKey = New ADOX.Key col = New ADOX.Column
'Open the connection Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WOMSTR.mdb")
'Open the Catalog Cat.ActiveConnection = Cn
'Create the table objTable.Name = "WorkOrder"
'Create and Append a new fields to the "Work Order" objTable.Columns.Append("WODate", DataTypeEnum.adDate) objTable.Columns.Append("WOInnInd", DataTypeEnum.adInteger) objTable.Columns.Append("WOTot", DataTypeEnum.adInteger) objTable.Columns.Append("WORS1", DataTypeEnum.adVarWChar, 20)
'Create and Append a new primary key objKey.Name = "PrimaryKey" objKey.Type = KeyTypeEnum.adKeyPrimary objKey.Columns.Append("WODate") objKey.Columns.Append("WOTInnInd") objTable.Keys.Append(objKey)
------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------- want to change WODate.format = Short Date change WODate.caption = "Work Order Date" change WODate.required = True want to change WOTot.format = General Number change WOTot.decimalplaces = 2 change WOTot caption = "Total Qty." ------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------
'Append the newly created table to the Tables Collection Cat.Tables.Append(objTable)
' clean up objects objKey = Nothing objTable = Nothing Cat = Nothing Cn.Close() Cn = Nothing End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hytga |
last post by:
hi can n e 1 tell me if there's a way to get the column properties from a
table?
properties like caption, description etc
thank you
|
by: Gram |
last post by:
Hello,
Can anyone help with the following:
I wrote an ASP script with allows me to select an MS Access database
from a folder, and it shows the tables in this database. If I click a
table,...
|
by: Larry |
last post by:
In Access each field has individual properties (font, size, color etc). Is
there a way around having to enter all these similar properties for each
field. This seems so redundant. Is there a...
|
by: Dixie |
last post by:
Can I set the Format property in a date/time field in code?
Can I set the Input Mask in a date/time field in code?
Can I set the Format of a Yes/No field to Checkbox in code?
I am working on...
|
by: Donald Grove |
last post by:
Is it possible to retrieve field properties from a table in access2000
using code?
I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as...
| |
by: Sukhanov Volodya |
last post by:
Hello, all!
Does anybody knows, how I can show an image field SQL Server using VB. NET ?
I have an database, which has an table with an field which has type 'image'
(the type of field)
I want...
|
by: sajithamol |
last post by:
I'm trying to read a properties file using BufferedInputStream and getResourceAsStream(),but getting "java.io.IOException: Stream closed' exception.
My properties file is not set in the classpath,...
|
by: ahmed222too |
last post by:
how can i check if a field is null using VB6
these codes donot work:
If rs("lemmaid").Value is null
If rs("lemmaid").Value = null
If rs("lemmaid").Value =""
|
by: ahmed222too |
last post by:
how can i check if an access field is null using VB6
these codes donot work:
If rs("lemmaid").Value is null
If rs("lemmaid").Value = null
If rs("lemmaid").Value =""
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |