Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use VB code to Add a new field to a linked table?

Status
Not open for further replies.

kramerica

Technical User
Jun 19, 2001
74
US
I have an Access Database that has a frontend and a backend. The application has been rolled out to different sites, and I need to add a couple of fields to one of the Backend tables.

I can very easily distribute new frontends to everyone, but I have not run into the problem of 'modifying' a backend table to add additional fields.

How can I use VB Code in the frontend to check table "HWAREINFO" to add 5 fields if they are not already there? Any ideas?

Kramerica
 


Dim TempDB As Database
Set TempDB = MyWorkspace.OpenDatabase(BE_DB_NAME)
If Not TempDB Is Nothing Then
Set MyTblDef = TempDB.TableDefs(TABLE_TO_BE_CHANGED)
If Not MyTblDef Is Nothing Then
Err.Clear
Set MyFld = MyTblDef(FIELD_TO_BE_CREATED)
If Err.Number <> 0 Then
With MyTblDef
.Fields.Append .CreateField(FIELD_TO_BE_CREATED, ITS_TYPE, 0)
End With
Err.Clear
End If
End If
Set MyFld = Nothing
Set MyTblDef = Nothing
endif
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top