PC Review


Reply
Thread Tools Rate Thread

DAO: CopyTableDef() ?

 
 
=?Utf-8?B?SGVucnk=?=
Guest
Posts: n/a
 
      30th Jun 2005
has someoned done already a 1:1 copy routine to to copy the exact tabe frome
one db to another ? like:

Function CopyTableDef (strDBSourceName$, strDBDestName$, strTableName$)

I have the impression that ".CreateField(fldSource.name, fldSource.Type,
fldSource.Size)" simply would not do a complete job......
 
Reply With Quote
 
 
 
 
Nick via AccessMonster.com
Guest
Posts: n/a
 
      30th Jun 2005
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.

Nick

--
Message posted via http://www.accessmonster.com
 
Reply With Quote
 
=?Utf-8?B?SGVucnk=?=
Guest
Posts: n/a
 
      30th Jun 2005
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.
>
> Nick
>
> --
> Message posted via http://www.accessmonster.com
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      1st Jul 2005
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
newsE747752-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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.