By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Loop Through Recordset and Kill

P: n/a
I use a function to read all of the files from a couple of directories
(and subfolders) and update a table(tblfiles) with the fullpath and
file name, the filesize and the date the file was created. I then
manually select files to delete by clicking on a yes/no checkbox. I
have a query (qryfiledelete) which selects all of the files from
tblfiles where the yes/no field is yes.

What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The error seems to indicate that the above code isn't in a procedure
(Sub or Function). Is it? Else, you are using DAO and don't have the
DAO Reference selected in the References. Or, rst!PathName may be a
NULL value. Does the query "qryFileDelete" have a criteria of
"PathName Is Not NULL"?

Rgds,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQBV9QoechKqOuFEgEQJnNACg4Ku94bQeo4swE26akM4nDw gh5qEAoOdf
PHMOTzPp8WJHRC9mLGw4ew3i
=g8r/
-----END PGP SIGNATURE-----

David Mitchell wrote:
I use a function to read all of the files from a couple of directories
(and subfolders) and update a table(tblfiles) with the fullpath and
file name, the filesize and the date the file was created. I then
manually select files to delete by clicking on a yes/no checkbox. I
have a query (qryfiledelete) which selects all of the files from
tblfiles where the yes/no field is yes.

What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David


Nov 12 '05 #2

P: n/a
tom
David,
Which version of Access are you using?

I suspect it would help things out if you specify the namespaces of
your variables. Specifically, you may be getting caught in the ADO/DAO
headache. I'm a DAO guy, so I'd say do something like this:

====================
Dim db As DAO.Database
Dim rst As DAO.Recordset
...
====================

You'll need to make sure you have a reference set to the DAO object
library.
(Also, it doesn't look like you're using that "strPathName" variable
either.)

And, make sure to cleanup at the end with:

====================
set rst = nothing
set db = nothing
====================

hth,
-td
What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David

Nov 12 '05 #3

P: n/a
If you want to delete the files, have a look at FileSystemObject which
should allow you to do this. I'd have a query I'd run through, find
the records wanted, get the name and path and then delete using
FileSystemObject.
to*@nuws.com (tom) wrote in message news:<c1**************************@posting.google. com>...
David,
Which version of Access are you using?

I suspect it would help things out if you specify the namespaces of
your variables. Specifically, you may be getting caught in the ADO/DAO
headache. I'm a DAO guy, so I'd say do something like this:

====================
Dim db As DAO.Database
Dim rst As DAO.Recordset
...
====================

You'll need to make sure you have a reference set to the DAO object
library.
(Also, it doesn't look like you're using that "strPathName" variable
either.)

And, make sure to cleanup at the end with:

====================
set rst = nothing
set db = nothing
====================

hth,
-td
What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David

Nov 12 '05 #4

P: n/a
Over kill (sic) for the job.

Terry

"Ryan" <ry********@hotmail.com> wrote in message
news:78**************************@posting.google.c om...
If you want to delete the files, have a look at FileSystemObject which
should allow you to do this. I'd have a query I'd run through, find
the records wanted, get the name and path and then delete using
FileSystemObject.
to*@nuws.com (tom) wrote in message

news:<c1**************************@posting.google. com>...
David,
Which version of Access are you using?

I suspect it would help things out if you specify the namespaces of
your variables. Specifically, you may be getting caught in the ADO/DAO
headache. I'm a DAO guy, so I'd say do something like this:

====================
Dim db As DAO.Database
Dim rst As DAO.Recordset
...
====================

You'll need to make sure you have a reference set to the DAO object
library.
(Also, it doesn't look like you're using that "strPathName" variable
either.)

And, make sure to cleanup at the end with:

====================
set rst = nothing
set db = nothing
====================

hth,
-td
What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David

Nov 12 '05 #5

P: n/a
David,
Check that you don't have a module called Kill, if you do rename it to
modKill.

Then try

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")
With rst
Do Until .EOF
strPathName = .Fields("PathName") & ""
if Len(strPathName) > 0 then
if Dir(strPathName) > 0 then
Kill strPathname
End if
End if
.MoveNext
Loop
End With

Terry
"David Mitchell" <da**************@talk21.com> wrote in message
news:c3**************************@posting.google.c om...
I use a function to read all of the files from a couple of directories
(and subfolders) and update a table(tblfiles) with the fullpath and
file name, the filesize and the date the file was created. I then
manually select files to delete by clicking on a yes/no checkbox. I
have a query (qryfiledelete) which selects all of the files from
tblfiles where the yes/no field is yes.

What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?
Thanks

David

Nov 12 '05 #6

P: n/a
da**************@talk21.com (David Mitchell) wrote in
news:c3**************************@posting.google.c om:
I use a function to read all of the files from a couple of directories
(and subfolders) and update a table(tblfiles) with the fullpath and
file name, the filesize and the date the file was created. I then
manually select files to delete by clicking on a yes/no checkbox. I
have a query (qryfiledelete) which selects all of the files from
tblfiles where the yes/no field is yes.

What I want to do is run a function which will delete (Kill?) these
files from the computer. I have searched google and can find lots of
examples of how to delete the files and only one : -

Dim db As Database
Dim rst As Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")

Do Until rst.EOF
Kill rst!PathName
rst.MoveNext
Loop

But get an error on the Kill line - Compile Error, Expected Variable
or Procedure, not Project.

Can anyone see what I am doing wrong?


Not opening Explorer?
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #7

P: n/a
Thanks Terry, works perfectly.

David
"Terry Kreft" <te*********@mps.co.uk> wrote in message news:<XI********************@karoo.co.uk>...
David,
Check that you don't have a module called Kill, if you do rename it to
modKill.

Then try

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strPathName As String

Set db=CurrentDb
Set rst =db.OpenRecordset("qryfiledelete")
With rst
Do Until .EOF
strPathName = .Fields("PathName") & ""
if Len(strPathName) > 0 then
if Dir(strPathName) > 0 then
Kill strPathname
End if
End if
.MoveNext
Loop
End With

Terry

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.