• time delay (Access2K, sr1a)

    Author
    Topic
    #371379

    I am running a ftp script from a batch file using the shell command. I use this to transfer a text file that I then want to import into a table. I am having a problem with the computer starting the script, but before the transfer is complete, it starts to run the import and the file isn’t available because it is being transferred. Is there a way to put a time delay between the shell command and the docmd.??. I have tried a for-next loop, but that ties up the computer and it seems like the transfer happens slower than ever. Or is the for-next loop the only way to slow down the execution of my code?

    Viewing 2 reply threads
    Author
    Replies
    • #590177

      … Look under Charlottes posts. She did something very similar to this with an FTP import.

    • #590202

      If you know how long the delay needs to be you can use this function:
      Function Pause(ByVal nSecond As Single)
      Dim t0 As Single
      t0 = Timer
      Do While Timer – t0 < nSecond
      Dim dummy As Integer
      dummy = DoEvents()
      If Timer < t0 Then t0 = t0 – 24 * 60 * 60 ' if we cross midnight, back up one day
      Loop
      End Function
      You pause the whole operation by 10 seconds for example by using Pause(10) at the appropriate point in the code.
      Peter

      • #590212

        It looks like Pause function will work great–The file only takes a fraction of a second to transfer, but the computer is speedy enough, that it was getting ahead of itself. Thanks.

    • #590207

      Will a time delay truly solve your problem. The time delay will need to be based on the size of the file, which, typically is unknown. You need to launch the transfer after the file is completely transferred. If you transfer files to a particular folder, you can test to see if the file is completely written by trying to copy it. You will receive an error message if the file is still being written and you try to copy it. Thus, if you receive an error message, catch the error and re-try copying the file at a later time specified by you. (You could try every ten minutes)

    Viewing 2 reply threads
    Reply To: time delay (Access2K, sr1a)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: