I am copying tables with this function; however there is major problem with it:
Access does not copy the primary index (where that key icon appears) which seems neccessary for many query options (later in the application). That means in the new table there is NO primary index..
Does anybody know how to set the primary index for the new table???
Function copytable(dbpath As String, tablekind As String, tablename As String, totablename As String)
Dim db As Database, rs As Recordset
If dbpath = "" Then
' ----- wenn dbpath leer, dann prüfen wir die internen managertabellen -----
Set db = CurrentDb
Else
' ----- wenn wir einen dbpath haben, prüfen wir die externe tabelle -----
Set db = DBEngine.OpenDatabase(dbpath)
End If
DoCmd.SetWarnings False
DoCmd.RunSQL ("SELECT [" & tablename & "].* INTO [default" & tablekind & "] FROM [" & tablename & "];"
DoCmd.TransferDatabase acExport, "Microsoft Access", dbpath, acTable, "default" & tablekind, totablename
DoCmd.SetWarnings True
Set db = Nothing
End Function
Thanks a lot
waldemar
Access does not copy the primary index (where that key icon appears) which seems neccessary for many query options (later in the application). That means in the new table there is NO primary index..
Does anybody know how to set the primary index for the new table???
Function copytable(dbpath As String, tablekind As String, tablename As String, totablename As String)
Dim db As Database, rs As Recordset
If dbpath = "" Then
' ----- wenn dbpath leer, dann prüfen wir die internen managertabellen -----
Set db = CurrentDb
Else
' ----- wenn wir einen dbpath haben, prüfen wir die externe tabelle -----
Set db = DBEngine.OpenDatabase(dbpath)
End If
DoCmd.SetWarnings False
DoCmd.RunSQL ("SELECT [" & tablename & "].* INTO [default" & tablekind & "] FROM [" & tablename & "];"
DoCmd.TransferDatabase acExport, "Microsoft Access", dbpath, acTable, "default" & tablekind, totablename
DoCmd.SetWarnings True
Set db = Nothing
End Function
Thanks a lot
waldemar