Results 1 to 11 of 11

Thread: Resolved Run time Error 52

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Resolved Resolved Run time Error 52

    Hello, I'm getting an Run-time error '52' Bad file name or number.
    I already search the forum but still can't see what cause the the problem, can somebody please help me.

    Thanks
    Tony.



    Code:
    tStockFile.FileNumber = OpenSTD%(tStockFile.FileName)
           Put tStockFile.FileNumber, FirstRecord&, tSd         <---------- line with error 52
         Close tStockFile.FileNumber
         Exit Function
      End If
    Last edited by Tony.; Mar 1st, 2015 at 08:38 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run time Error 52

    What code is in the OpenSTD function?
    I would suspect that the file is either not opened properly or is read only

    Also would be good to know the path and the operating system being used.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Run time Error 52

    Quote Originally Posted by DataMiser View Post
    What code is in the OpenSTD function?
    I would suspect that the file is either not opened properly or is read only

    Also would be good to know the path and the operating system being used.
    The OS is WIN7 64 but this program works before on that PC.
    The code for the OpenSTD function is
    Code:
    Function OpenSTD%(tFile$)
              OpenSTD% = OpenFileRandomRWLocked(tFile$, RecordLenth&)
    End Function
    Thanks

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run time Error 52

    Still would like to know the path, also is it on a network share?

    Where is recordlength dimmed and assigned?

    Have you tried stepping through the code to insure that the path/filename is correct and accessible and that recordlength is set correctly?

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Run time Error 52

    Is OpenFileRandomRWLocked an intrisic VB4 function?
    Or is this a wrapper on some other call?

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run time Error 52

    Looks like a wrapper to me.

    Makes very little sense to me to create a wrapper to call a wrapper.
    I prefer to keep my open, read/write and close routines all in the same routine when ever possible. Makes the code mush easier to follow.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Run time Error 52

    Hi DataMiser, I'm trying to fix this program and learn during the process, I'm sorry I don't know to much yet, so thank you for your patience with a learning student.


    Look at this code showing the main path as app.path and another tPath$ is this the path you mention.


    Code:
    Sub Main()
    
      tCommand$ = Trim(Command$)
      Call SetupGlobals(App.Path)
    Last edited by Tony.; Mar 1st, 2015 at 08:36 PM.

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run time Error 52

    You still have not answered the question.

    What path is being used and is it a share

    If your program is installed in the typical program files location and you are using app.path then that is a potential problem as that folder will be read only

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Run time Error 52

    Hi DataMiser, some more info.
    No, is not on a network share.
    And the program is not on the typical program , neither use the registry.
    The program resides inside a folder, that folder has a few more inside.
    The folder with the program can be moved to another computer, and can run from any location, desktop, my document etc.. don't need to be installed.
    The .VBP file needs to be start from inside appDir folder.
    Inside the appDir has one folder where the files holding the data are created and stored, 2 files one ext .dat and another .std
    Thanks
    Last edited by Tony.; Feb 26th, 2015 at 09:34 PM.

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run time Error 52

    So even after asking 3 times I still do not know what the path is when your problem occurs. This may or may not be the problem but without knowing what it is can't be sure.
    We still have not saw the code that actually opens the file.
    You also did not say if you have tried stepping through the code.

    Data files can not be located at just any location on the newer operating systems some folders are restricted and will not allow you to write to them such as the root folder, windows folder, program files folder ...

    The error indicates that either the file was not opened properly, the filenumber is incorrect or there was a problem writing to the file for some other reason.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Run time Error 52

    I found the problem, the file was not opened properly.
    Thanks to all

Posting Permissions

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



Click Here to Expand Forum to Full Width