If the goal is to make a backup copy of a table into another database, this
should do it:
Private Function BackupTable(dbLocal As DAO.Database, dbBackup As
DAO.Database, _
strTable As String, rsError As DAO.Recordset, strErrMsg As String) As
Boolean
On Error GoTo Err_Handler
'Purpose: Create a copy of this table into the target database.
'Arguments: dbLocal = this database.
' dbBackup = the backup database.
' strTable = name of the table to be backed up.
' rsError = the error table in the backup database to append
error messages to.
' strErrMsg = string to append error messages to if the error
messages can't be written.
Dim strSql As String
DoCmd.Echo True, "Backing up table: " & strTable 'Display the name of
the table.
strSql = "SELECT * INTO [" & strTable & "] IN """ & dbBackup.Name & """
FROM [" & strTable & "];"
dbLocal.Execute strSql, dbFailOnError
BackupTable = True
Exit_Handler:
Exit Function
Err_Handler:
Call WriteError(dbBackup, rsError, strTable, acTable, Err.Number,
Err.Description, strErrMsg)
Resume Exit_Handler
End Function
There's a more complete version of this backup code at:
http://allenbrowne.com/unlinked/Backup.txt
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Henry" <(E-Mail Removed)> wrote in message
news

E747752-B60D-4581-A503-(E-Mail Removed)...
> the bizzar thing is: when I loop through the new table to fill in data,
> at
> the 9th record it says : Runtime error -2147217887 Textfield of length
> null
> not allowed :-(
>
> "Nick via AccessMonster.com" wrote:
>
>> The function is built into VBA, there are a couple of ways to go about
>> it,
>> but I always use
>>
>> DoCmd.TransferDatabase (...)
>>
>> If you want the field names only, not the data, enter "True" for the
>> Structure Only argument.