Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File access denied

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
WIN XP SP2 - VFP6
The code below is a section from an EPOS system which has been working at 3 seperate locations for over 6 years.
The client reported that 1 of the machines is falling over.
Code:
error - file access denied
As I work some distance from his site, I sent him a test version of the app in which I inserted wait windows throughout this section.
The error occurs when the highlighted query is run.
All the versions of the app were installed from the same set up disks.
The only other possible difference is that the machine with the error has additional programs and apps installed but the VFP app has been re-installed from the original disk and is identical to the other machines.
DAYSALES, ASTOCK and other tables are accessed successfully throughout the rest of the application with no problems.
Could something external to the program be preventing the query from running?

I realise that faults of this nature can be difficult to resolve but would welcome any suggestions as to what may be the cause.

Code:
	IF LASTKEY()=13
		SELECT ASTOCK
		SET ORDER TO CODE
		SELECT DAYSALES
		SET ORDER TO CODE
		COUNT ALL FOR DAYSALES.CODE=ALLTRIM(THIS.VALUE) TO HOWMAN
		IF HOWMAN>0
			REFCODE=ALLTRIM(THIS.VALUE)
			SELECT ASTOCK
			SEEK REFCODE
			IF FOUND()
				TYTL="Listing for "+ASTOCK.PRODUCT
			ELSE
				TYTL="Product not found."
			ENDIF
			SELECT DAYSALES
			SET ORDER TO SALE_NUM
			THISFORM.LINE_DETS.VISIBLE=.T.
[red]
			SELECT DAYSALES.DATE,DAYSALES.TIME,DAYSALES.CODE,ASTOCK.PRODUCT,DAYSALES.QTY,;
					DAYSALES.EACH;
					FROM Z:\ASTOCK.DBF ASTOCK INNER JOIN Z:\DAYSALES.DBF DAYSALES ON ASTOCK.CODE = DAYSALES.CODE;
					WHERE (DAYSALES.CODE=REFCODE);
					ORDER BY DAYSALES.DATE;
					INTO CURSOR KEEFY
			SELECT KEEFY
[/red]
			GO BOTTOM
			BROW

			RDATE=KEEFY.DATE
			RCODE=KEEFY.CODE
			RPROD=KEEFY.PRODUCT
			RPRIC=KEEFY.EACH
			RQTY=KEEFY.QTY
			THISFORM.REFRESH
		ELSE
			THISFORM.LINE_DETS.VISIBLE=.F.
			=MESSAGEBOX("No Items with code "+ALLTRIM(THIS.VALUE)+" in table")
		ENDIF
	ENDIF

Keith
 

Hi Keith,

You obviously have DaySales and AStock open before you start the query (because you refer to them in the preceding code), but you are referencing them with their full paths in the SELECT. Basically, there's nothing wrong with that, but it could be masking the real reason for the error.

I'd start by removing the paths from the SELECT. In other words, do this:

Code:
SELECT DAYSALES.DATE,DAYSALES.TIME,DAYSALES.CODE,ASTOCK.PRODUCT,DAYSALES.QTY,;
                    DAYSALES.EACH;
                    FROM ASTOCK ASTOCK INNER JOIN DAYSALES DAYSALES ON ASTOCK.CODE = DAYSALES.CODE;
                    WHERE (DAYSALES.CODE=REFCODE);
                    ORDER BY DAYSALES.DATE;
                    INTO CURSOR KEEFY

The point is that the SELECT might have been trying to access different files from the ones that you had already opened. If those files existed, and happened to have been opened exclusively by someone else, that would explain the error.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike - I will give that a try when their IT guy returns from holiday.

The machine where the error is occurring is the only one of the 3 instances which isn't networked so there is only a single app acessing the data.
The strange part is, that this error has only recently occurred after many months of faultless operation.

Keith
 

Keith,

Keep in mind that my suggestion wasn't meant to be a solution -- just something to eliminate. The fact that the machine isn't networked suggests that it isn't a question of someone else having the file open exclusively after all.

The only other thing I can think of is that there is something wrong with the user's Temp directory -- if they don't have write access to it, for instance. My reason is that it is the Temp directory where VFP will try to create the cursor.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike
That sounds more like the kind of problem they are facing.

Keith
 
Just to be clear ...

You indicated the error occurred when the Query statement was being executed. That would mean that the SELECT KEEFY statement never executes at all. Is that correct ?

I bring this up because you do have it highlighted as though it were part of the preceding statement. But you may have just highlighted it inadvertently.



Don


 
Sorry
I highlighted both as they create 2 seperate errors.
First one is file access denied for the query that is unable to execute.
The second error occurs when it tries to access the cursor which has not been created.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top