Kill File

  • Thread starter Thread starter Albert D. Kallal
  • Start date Start date
A

Albert D. Kallal

I am guessing, but it looks like you want to take todays date..and subtract
7..

try:

dim strFile as string

strFile = "C:\Ps\BackUp\" & _
Format(Date - 7 , "yyyymmdd") & ".MDB"

If Dir(strFile ) <> Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else
Kill strFile
End If

You don't need to add the " to the actual string used....
 
I'm trying to kill a file bt I know my code isn't right and I can't
figure out the syntax, any help is appreciated.
Thanks
DS

If Dir("C:\Ps\BackUp\Format(Date, ""yyyymmdd"")-7 & "".MDB""") <> Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else:
Kill C:\Ps\BackUp\Format(Date, "yyyymmdd")-7 & ".MDB"
End If
 
Albert said:
I am guessing, but it looks like you want to take todays date..and subtract
7..

try:

dim strFile as string

strFile = "C:\Ps\BackUp\" & _
Format(Date - 7 , "yyyymmdd") & ".MDB"

If Dir(strFile ) <> Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else
Kill strFile
End If

You don't need to add the " to the actual string used....
Thanks Albert! Perfect!
DS
 
Albert said:
I am guessing, but it looks like you want to take todays date..and subtract
7..

try:

dim strFile as string

strFile = "C:\Ps\BackUp\" & _
Format(Date - 7 , "yyyymmdd") & ".MDB"

If Dir(strFile ) <> Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else
Kill strFile
End If

You don't need to add the " to the actual string used....
OOPS!

The first line come up in red !!!

If Dir(strFile) <> Then

DS
 
DS said:
DS wrote:
I have this. it seems to work? Or am I missing something?
Thnks
DS

Dim strFile As String

strFile = "C:\Proserv\BU\" & _
Format(Date - 7, "yyyymmdd") & ".MDB"

If Dir(strFile) = "" Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else
Kill strFile
End If

Looks good to me.

Ed Metcalfe.
 
DS wrote:
I have this. it seems to work? Or am I missing something?
Thnks
DS

Dim strFile As String

strFile = "C:\Proserv\BU\" & _
Format(Date - 7, "yyyymmdd") & ".MDB"

If Dir(strFile) = "" Then
DoCmd.OpenForm "frmMsgInfo"
Forms!frmMsgInfo!TxtMsg = "Doesn't Exsist"
Else
Kill strFile
End If
 
Back
Top