PC Review Forums Newsgroups Microsoft Access Microsoft Access VBA Modules purge files with vb and access queries

Reply

purge files with vb and access queries

 
Thread Tools Rate Thread
Old 01-08-2003, 06:17 PM   #1
brian
Guest
 
Posts: n/a
Default purge files with vb and access queries


I have a VB app that searches 5 directories from the
root.

For example:

Function PurgeJobFiles()
Dim db As Database, rs As Recordset
Const OMNIchrd_PATH = "N:\OMNIchrd\"

On Error Resume Next

Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.OpenRecordset("qryDelete_Shop_File",
DB_OPEN_DYNASET) ' Create dynaset.

rs.MoveFirst ' Move to first record.
If Err <> 0 Then
rs.Close ' Close recordset
On Error GoTo 0 ' Reset error processing
Exit Function ' Exit
End If

Do Until rs.EOF ' Loop until no matching
records.
Kill OMNIchrd_PATH & rs!JOB_NO & "*.*" '
Delete OMNI files.

rs.MoveNext ' Move to next record.
Loop ' End of loop.
MsgBox "Files have been deleted", vbOKOnly, "Deleted
Files"
rs.Close ' Close recordset
On Error GoTo 0 ' Reset error processing

End Function

This deletes every record in the root directory that
matches the query. I have been given a new task to
search directories with sub directories within
subdirectories. Is there a dynamic way of searching
through the root directory and hit all the sub
directories?

Thanks

  Reply With Quote
Old 04-08-2003, 04:06 PM   #2
Lance McGonigal
Guest
 
Posts: n/a
Default Re: purge files with vb and access queries

If you continue to use the Dir statement doesn't it show full path names for
everything in the directory and it's subs? If so, just store in a temp
table and compare to the query via a join. delete the survivors.

Just a thought

Lance

"brian" <brians@lbrspec.com> wrote in message
news:0bd501c35848$7011a500$a601280a@phx.gbl...
> I have a VB app that searches 5 directories from the
> root.
>
> For example:
>
> Function PurgeJobFiles()
> Dim db As Database, rs As Recordset
> Const OMNIchrd_PATH = "N:\OMNIchrd\"
>
> On Error Resume Next
>
> Set db = DBEngine.Workspaces(0).Databases(0)
> Set rs = db.OpenRecordset("qryDelete_Shop_File",
> DB_OPEN_DYNASET) ' Create dynaset.
>
> rs.MoveFirst ' Move to first record.
> If Err <> 0 Then
> rs.Close ' Close recordset
> On Error GoTo 0 ' Reset error processing
> Exit Function ' Exit
> End If
>
> Do Until rs.EOF ' Loop until no matching
> records.
> Kill OMNIchrd_PATH & rs!JOB_NO & "*.*" '
> Delete OMNI files.
>
> rs.MoveNext ' Move to next record.
> Loop ' End of loop.
> MsgBox "Files have been deleted", vbOKOnly, "Deleted
> Files"
> rs.Close ' Close recordset
> On Error GoTo 0 ' Reset error processing
>
> End Function
>
> This deletes every record in the root directory that
> matches the query. I have been given a new task to
> search directories with sub directories within
> subdirectories. Is there a dynamic way of searching
> through the root directory and hit all the sub
> directories?
>
> Thanks
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off