Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete the last record

0 views
Skip to first unread message

morgan

unread,
Nov 13, 2007, 11:22:02 AM11/13/07
to
Hello everybody, I'm making my MP3 collection db importing xls files created
by an MP3 tag editor. I have the following code to append the xls file to my
access table and everything work fine. Since the last row of the xls file is
always "this list has been created with..." I'd like to modify the code to
delete the last record appended on my access table and then refresh the form,
in order to get immeditely the new records. I'm using access 2003.
Tks in advance

Private Sub Comando10_Click()

Dim dlg As FileDialog
Dim Importfile As String

Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.Title = "Select the Excelfile to import"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel Files", "*.xls", 1
.Filters.Add "All Files", "*.*", 2
If .Show = -1 Then
Importfile = .SelectedItems(1)

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"Db_MP3", Importfile, True, "A1:E1000"
Else
Exit Sub
End If
End With

End Sub

John Spencer

unread,
Nov 13, 2007, 12:26:29 PM11/13/07
to
Why not run a delete query that deletes any record that has the Phrase "This
List has been created "

You can probably just add the following line (all one line) of code to your
current code.

CurrentDb().Execute "DELETE FROM db_MP3 WHERE [Somefield] Like 'This List
has been created*'"

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

"morgan" <mor...@discussions.microsoft.com> wrote in message
news:034FFDE9-3AF9-4948...@microsoft.com...

morgan

unread,
Nov 15, 2007, 2:45:01 AM11/15/07
to
Hi John, sometimes i try to complicate my life....
Tks

"John Spencer" wrote:

> Why not run a delete query that deletes any record that has the Phrase "This
> List has been created "
>
> You can probably just add the following line (all one line) of code to your
> current code.
>
> CurrentDb().Execute "DELETE FROM db_MP3 WHERE [Somefield] Like 'This List
> has been created*'"
>
> --
> John Spencer
> Access MVP 2002-2005, 2007
> Center for Health Program Development and Management
> University of Maryland Baltimore County

> ..

0 new messages