Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wrong function (Access 2000)

    I have built a wrong function ,it doesnt work and i cannot corect it.It gives the
    message " file not found" although the file called "BE" is in the folder.
    The function is the following :


    Private Function ArchiveBE()
    ' first part of the function
    If Dir("C:BEBE.zip", vbNormal) <> "" Then
    Kill "C:BEBE.zip"
    Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE C:BE"
    End If
    ' second part of the function

    Dim strSource As String
    Dim strDest As String
    strSource = "C:BEBe.zip"
    strDest = "C:BEArchiveBEBE" & Format(Date, "yyyymmdd") & ".zip"
    FileCopy strSource, strDest

    End Function

    Interesting, if i perform t separately he two parts of the function they work but taken together they it does not.
    How could i correct it ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: wrong function (Access 2000)

    The line

    Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE C:BE"

    seems strange to me - the second argument to WZZip is the name of a folder. It should be a file specification.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: wrong function (Access 2000)

    Does the file BE have an extension ?

    Is it meant to be BE.mdb for example?

    The logic seems odd to me.

    In the first part, the zip file is deleted and recreated if it already exists.

    The second part copies the zip file.

    If the zip file did not exist at the start, if won't get created, so it won't be possible to copy it.

    I think you need to move the line that creates the new zip file so that it comes after the 'end if '.
    Regards
    John



  4. #4
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: wrong function (Access 2000)

    Thank to you both for the attention you have given to my problem.

    Now to answer your questions.

    The line Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE C:BE" works,
    it puts the zipped file into the folder C:BE.


    The first part of the function creates an BE.mdb file in the folder C:BE :

    If Dir("C:BEBE.zip", vbNormal) <> "" Then
    Kill "C:BEBE.zip"
    End If
    Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE C:BE"



    If i perform it itself, without the second part, it is OK. I have follwed your advice and put
    the Shell line after the IF


    The second line copies the zipped file BE into the folder BE/arcvive with the date function:

    Dim strSource As String
    Dim strDest As String
    strSource = "C:BEBe.zip"
    strDest = "C:BEArchiveBEBE" & Format(Date, "yyyymmdd") & ".zip"
    FileCopy strSource, strDest

    If performed by itself, without the frst part, also works and the result is OK.
    However, when i perform the whole function, i get this mesage "file not found"
    I guess the function cannot recognize that the zipped file BE already exists.
    But the function is not right, since the zipped file is already there.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: wrong function (Access 2000)

    I suspect it's a timing problem. Try inserting these lines between the two parts of your function:

    Do While Dir("C:BEBE.zip") = ""
    DoEvents
    Loop

  6. #6
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: wrong function (Access 2000)

    Thank you for your reply.I have put your lines between my two parts,this time the function works, but the strange erors continued.
    Sometimes i get the message Permission denied and when i try second time, then the message is "file not found"
    Obvisousy this has something do to with the Winzip finctions.
    if this is too difficult, you could help me in anoher way :
    Actually i have two parts in the function, because i cannot send the dated formatted zipped file to the folder C:BE:Archive

    I can make a zipped file with the date format in the folder C:BE :

    Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE" & Format(Date, "yyyymmdd") & " C:BE"

    It works.I get a zipped BE in the folder C:BE. However i cannot send it to the desired folder.If only i could send it to the folder C:BeArchive i will succeed.Can i change the shell line given above ?

    The following line is wrong :
    Shell """C:Program FilesWinZipWZzip.exe"" C:BEBE" & Format(Date, "yyyymmdd") & " C:BEArchiveBE"
    With the above line i get no error but no file is copied.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: wrong function (Access 2000)

    The first argument for WZZip is the zip file to be created, the second is the specification of the files to be zipped. So if you want to create a zip file in C:BEArchive, you must put that in the first argument.
    <code>
    Shell """C:Program FilesWinZipWZzip.exe"" C:BEArchiveBE" & Format(Date, "yyyymmdd") & " C:BE"
    </code>
    Today, this should create a zip file BE20050903.zip in C:BEArchive.

  8. #8
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: wrong function (Access 2000)

    and so it does ! Thanks Hans.I

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •