-
Feb 25th, 2015, 08:35 PM
#1
Thread Starter
Junior Member
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.
-
Feb 25th, 2015, 10:06 PM
#2
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.
-
Feb 25th, 2015, 10:45 PM
#3
Thread Starter
Junior Member
Re: Run time Error 52
Originally Posted by DataMiser
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
-
Feb 25th, 2015, 11:10 PM
#4
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?
-
Feb 26th, 2015, 05:07 AM
#5
Re: Run time Error 52
Is OpenFileRandomRWLocked an intrisic VB4 function?
Or is this a wrapper on some other call?
-
Feb 26th, 2015, 11:43 AM
#6
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.
-
Feb 26th, 2015, 06:07 PM
#7
Thread Starter
Junior Member
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.
-
Feb 26th, 2015, 06:56 PM
#8
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
-
Feb 26th, 2015, 09:25 PM
#9
Thread Starter
Junior Member
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.
-
Feb 26th, 2015, 10:10 PM
#10
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.
-
Mar 1st, 2015, 08:32 PM
#11
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|