Mike Mueller said:
Quick overview on the process I am using-
I have a table 'current', which is the backbone of my
database for generating documents for the customs service.
The addresses are stored in another table, and linked to
'current'. On occasion, I have 2 sets of shipments going
out, so I created an archive command which copies the
'current' table as another table via a query, and then
another query deletes the records in the 'current' table and
get the second manifest going.
As I am the primary user, it is really no big deal for me to
open the archived table and select all-copy and then open
the 'current' table and select all-paste. I am just trying
to make it a little easier for the occasions that this
occurs and I am gone
I had though of the date-range, but there are several
occassions where I will have 2 or 3 shipments go on the same
day. It is hard enough to keep the 4 packages going to the
same address apart from a single shipment, adding in 3 more
would make nearly impossible to keep it straight
I tried the following, but was never able to select the
table which was opened:
Private Sub ImportRecord_Click()
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdSelectAll
DoCmd.RunCommand acCmdCopy
DoCmd.OpenTable "Current", acViewNormal, acEdit
DoCmd.RunCommand acCmdSelectAll
DoCmd.RunCommand acCmdPaste
DoCmd.Close acTable, "Current"
End Sub
Mike
I've been thinking about what you want to do and I think I might have come
up with a way to get you moving forward.
It appears that you have a form with a button (ImportRecord) on it. Add a
combo box - I named it "cboListTables" - and set the following properties:
Format tab:
Column count: 2
Column widths: 0;2 (or something wide)
Data tab:
Limit to list: YES
Record source type: Table/Query
Record source:
SELECT msysobjects.Name, [name] & " - " & [dateupdate] AS LastUpdate FROM
msysobjects WHERE (((msysobjects.Name) Not Like 'msys*' And Not
(msysobjects.Name)='current') AND ((msysobjects.Type)=1)) ORDER BY
msysobjects.DateUpdate DESC;
I modified the code for the ImportRecords button:
'*** begin code ***
Private Sub ImportRecord_Click()
Dim strSQL As String
Dim response As Integer
Dim msg As String
' check for no selection
If IsNull(Me.cboListTables) Then
MsgBox "Please select a table"
Me.cboListTables.SetFocus
Me.cboListTables.Dropdown
Exit Sub
End If
msg = "Do you want to copy records from table" & Me.cboListTables & " to
table CURRENT?"
msg = msg & vbCrLf & vbCrLf
msg = msg & "All records in table CURRENT will first be deleted!!!"
response = MsgBox(msg, vbYesNo + vbDefaultButton2 + vbQuestion)
If response = vbYes Then
strSQL = "DELETE * FROM Current;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Current SELECT * FROM " & Me.cboListTables & ";"
CurrentDb.Execute strSQL
'you could close the form here after update
'DoCmd.Close acForm, Me.Name
End If
End Sub
'*** end code ***
NOTE: The archive table structure must match the table CURRENT structure or
the code bombs. Do you have a naming convention for the archive tables so you
could limit the tables names returned to *just* the archive tables?
Anyway, HTH