Re: make backup of table before edit



How about using the CopyObject command?
Assuming the table you want to copy is named "Employees", you could use

Dim strName as String

strName = InputBox("Enter new table name")
If Len(strName) > 0 THEN
DoCmd.CopyObject , strName, acTable, "Employees"
'Yes the first comma is supposed to be there. The first argument is
'optional and leaving it blank means you want to use the current
'database as the destination for the copy.
End if


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"kami" <kami@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AA43E7F1-208F-4667-8055-7203AD185FAE@xxxxxxxxxxxxxxxx
I have a table that I am updating it via a data entry form, but prior to
updating the table in the form I want to make a backup copy of the table.
When the form opens I want Access to ask for a new table name and copy the
content of current table into the new table as given by the input box
prompt.
I am using input box but cannot use the users input for the new table name
since runsql doesn't accept string variable (StrName) as the new table
name
during insert into.

Private Sub Form_Open(Cancel As Integer)
Dim StrName As String
DoCmd.OpenTable table1, acViewPreview 'Open current table"
StrName = InputBox("Enter new table Name:")
docmd.RunSQL (SELECT Table1.name, Table1.[last name] INTO StrName FROM
Table1) 'Name the new table using the input box
DoCmd.Close acDefault, table1, acSaveNo, 'close current table prior to
editing
End Sub

Can anyone help and suggest a solution. Thanks



.



Relevant Pages

  • Re: Saving to a specific file with a specific file name
    ... Dim strName As String ... 'Remove cell marker from string ... ChangeFileOpenDirectory (strPath) ...
    (microsoft.public.word.vba.general)
  • Re: INSERT INTO statement
    ... Dim StrSQL as String ... Dim strName As String ... O Wilson wrote: ...
    (microsoft.public.access.gettingstarted)
  • Re: Referencing subform during module code
    ... This would work at the form level, but not at the subform. ... Dim strName As String ...
    (comp.databases.ms-access)
  • Re: INSERT INTO statement
    ... get treated as if it were a division problem. ... Dim StrSQL as String ... Dim strName As String ...
    (microsoft.public.access.gettingstarted)
  • Re: concatenate WCHAR*
    ... > LPWSTR SayHello ... > return kTemp; ... > i want to add "Hello " to strName. ... not safe to prepend another string to it. ...
    (microsoft.public.vc.language)

Quantcast