Discussion Locked

Renaming A Table

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Does anyone know how to rename a table using MS Access 97 VBA????

Thanks!

3 replies

by roc180

Use the provided function

'****************************
'Use for testing
Sub Test_ChangeName()
MsgBox _
Change_TableName("Tbl_1", "Tbl_NewName")
End Sub

'*****************************************
'Function finds TBL(strOldTBL_Name)and
'changes name to new name (strNewTBL_Name)

Function Change_TableName(strOldTBL_Name As String, strNewTBL_Name As String) As Boolean

Dim TdfChange As TableDef
Dim boolChange As Boolean

With CurrentDb
For Each TdfChange In .TableDefs
If TdfChange.Name = strOldTBL_Name Then
TdfChange.Name = strNewTBL_Name
boolChange = True
End If
Next TdfChange

If boolChange Then
.TableDefs.Refresh
End If
End With

Change_TableName = boolChange
End Function

Good Luck
Neal Martinelli

This discussion is closed to new replies.