General discussion

Locked

MS Access 2000: Change data type w/macro

By zool326 ·
Is there a way to open a table in the design view in Access and change the field data type to date through a macro command?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

MS Access 2000: Change data type w/macro

by colm_maguire In reply to MS Access 2000: Change da ...

Hi Zool,

Don't know if you can use a macro but here's some VBA code straight from the Help files that you could modify to set the value if the datas type to Date/Time. You would need to have some way of collecting the name of the field to change (if you want the code to be flexible) such as a combo box on a form that uses a field listing for a table inits drop down menu.

Sub NewField()
Dim dbs As Database, tdf As TableDef
Dim fld As Field

' Return reference to current database.Set dbs = CurrentDb
' Return reference to Employees table.
Set tdf = dbs.TableDefs!Employees
' Create new Field object.
Set fld = tdf.CreateField("SSN#")
' Set Type and Size properties of Field object.
fld.Type = dbText
fld.Size = 11' Append field.
tdf.Fields.Append fld
' Enumerate all fields in Fields collection of TableDef object.

For Each fld in tdf.Fields
Debug.Print fld.Name
Next fld
Set dbs = Nothing
End Sub

Any reason why you don't just do it manually?

Collapse -

MS Access 2000: Change data type w/macro

by zool326 In reply to MS Access 2000: Change da ...

Trying not to do it manually, to avoid having to do the user training. Thanks for you help!

Collapse -

MS Access 2000: Change data type w/macro

by zool326 In reply to MS Access 2000: Change da ...

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums