deleting files based on a list

  • Thread starter Thread starter nokia3650
  • Start date Start date
N

nokia3650

I want to delete files from a list that i have in ms access database

how can i do that?

i have a list of files that have to bo deleted,all files are in same folder.

thx


rene

deleting files based on a list
 
hi Rene,
I want to delete files from a list that i have in ms access database
i have a list of files that have to bo deleted,all files are in same folder.

Dim rs As ADO.Recordset

Set rs = New ADODB.Recordset
rs.Open "SELECT Filename, IsDeleted FROM Files WHERE NOT IsDeleted", _
CurrentProject.Connection, _
adOpenDynamic, adLockOptimistic

Do While Not rs.Eof
Kill Path & rs![Filename]
rs![IsDeleted] = True
rs.Update
rs.MoveNext
Loop

rs.Close
Set rs = Nothing


mfG
--> stefan <--
 
Danke stefan or thx stefan

can u help me with these:

Public Function ImportAsbisxxx()

Dim db As Database
Dim rs As Recordset
Dim kom As Integer
Dim sqlupit As String
Dim imetabele As Variant

Set db = CurrentDb()
kom = 2
sqlupit = "SELECT Sheetovi.F1 as ime_sheeta FROM Sheetovi WHERE
Sheetovi.AutoBroj=" & kom
Set rs = db.OpenRecordset(sqlupit)
imetabele = rs!ime_sheeta & "!A6:I250"

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False, imetabele

End Function

and it doesnt work.
if i change :

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False, imetabele

to

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False,
"sheetname!A6:I250"

then it works.

i also looked if the sql gives me the right name and it is all ok

is the problem in data type of imetabele

thx


rene


Stefan Hoffmann said:
hi Rene,
I want to delete files from a list that i have in ms access database
i have a list of files that have to bo deleted,all files are in same
folder.

Dim rs As ADO.Recordset

Set rs = New ADODB.Recordset
rs.Open "SELECT Filename, IsDeleted FROM Files WHERE NOT IsDeleted", _
CurrentProject.Connection, _
adOpenDynamic, adLockOptimistic

Do While Not rs.Eof
Kill Path & rs![Filename]
rs![IsDeleted] = True
rs.Update
rs.MoveNext
Loop

rs.Close
Set rs = Nothing


mfG
--> stefan <--
 
hi,
Danke stefan or thx stefan
First on is okay.
i also looked if the sql gives me the right name and it is all ok
is the problem in data type of imetabele
Try
Dim imetabele As String

also test

DoCmd.TransferSpreadsheet acImport, , _
"Asbis_novo", "Z:\Realis\Cjenici\Asbis\asbis.xls", False,
CStr(rs!ime_sheeta) & "!A6:I250"
..

When using recordsets it is a good practice to close and destroy them
due to some minor bugs in the memory management:

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("")
'do something with it
rs.Close
Set rs = Nothing

mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top