Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    time delay (Access2K, sr1a)

    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?

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: time delay (Access2K, sr1a)

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

    Gary
    (It's been a while!)

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: time delay (Access2K, sr1a)

    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

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: time delay (Access2K, sr1a)

    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)
    Regards,

    Gary
    (It's been a while!)

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pause function works

    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.

Posting Permissions

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