Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Make ordering in grid
Message
 
To
12/12/2003 11:47:19
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00858599
Message ID:
00858935
Views:
39
>I have a single table with these fields:
>ItemNo.,Description,Brand,Quantity,DocumentNumber,Expiry date
>
>the Procedures is in this way for user:
>1- user will write Document Number To Capture data by Remote view From Another system,
>After that he will write an Expir date for each Item No, Then he will save it to Another table Called Prodexp.
>Note: This Procedure is like a Person who writes a bill
>
>2- In Another Form the user will write ItemNo., In grid Will show him all Description,Brand,Quantity and Expir Date for same ItemNo. with deferent Document Number, This Form made it to let user takes from quantity but system should let him takes from nearest expire date until user makes the quantity equal 0, when it become 0 user can takes quantity from next nearest expire date, and so on

Hi Abedalrahim,
I checked your project. As I can see you are talking about form PRODEXP1.SCX
This whole desogn is very questionable.

First what data you want to keep in PRODEXP table? It really works like a temporary cursor. So if we look at the code in your textbox.valid that is supposed to get the remote data and fileter the table - see my comments I added there.
LOCAL lcDoc,lntotrec

lcDoc=ALLTRIM(THIS.VALUE)
THISFORM.expgrid.RECORDSOURCE=''
* What is the meaning of data in PRODEXP table, shown in the grid initially?
* Looks like it has the data from the previous search
* so really it works as a temporary cursor.

IF EMPTY(THIS.VALUE)
	MESSAGEBOX("Please enter the GI No. ",0)
	RETURN
	* Should be RETURN 0 here, if you want to keep the focus in the textbox.
	* and better to have more data handling here to let the user at least 
	* close the form without entering anyting
ENDIF
IF lcDoc='99'
	RETURN .T.
ENDIF

SELECT 1
* It is not a good practice to use work area numbers
* You should use SELECT 0 and then refer the workareas by alias names


USE EXP!junk2
* Here you just dumped your PRODEXP table and opened the view instead

* Junk2 is the parameterized remote view. Since I don't have your remote database 
* I extracted the view definition through GENDBC.PRG
*!*	CREATE SQL VIEW "JUNK2" ;
*!*		REMOTE CONNECT "sqlanywhere" ;
*!*		AS SELECT Transactiondetails.ProductCode, ;
*!*		Productmaster.ProductDescription, ;
*!*		Productmaster.ManufUniqueId, ;
*!*		Productmaster.ProdAreaIdentifier1Id, ;
*!*		Transactiondetails.PackSize, ;
*!*		Transactiondetails.PacksQuantity,  ;
*!*		Transactiondetails.TotalSinglesQuantity, ;
*!*		Transactiondetails.trancurrsnglcostprcinctax-Transactiondetails.trancurrsnglcosttax AS unitcost, ;
*!*		Transactiondetails.acctcurr1costvalueinctax-Transactiondetails.acctcurr1costtax AS totalcost,;
*!*		TRANSACTION.DocumentNumber ;
*!*		FROM DBA.Transactiondetails Transactiondetails,;
*!*		  DBA.TRANSACTION TRANSACTION, ;
*!*		  DBA.Productmaster Productmaster ;
*!*		  WHERE TRANSACTION.LocCreatedClientNumber = Transactiondetails.LocCreatedClientNumber ;
*!*		    AND Productmaster.ProductCode = Transactiondetails.ProductCode ;
*!*		      AND Transactiondetails.TransactionNumber = TRANSACTION.TransactionNumber ;
*!*		        AND TRANSACTION.DocumentNumber = ?lcDoc


COUNT TO lntotrec
* You don't need to use COUNT TO 
* as you can just get "RECCOUNT("junk2")
* or check _TALLY

IF lntotrec=0
	MESSAGEBOX("Please enter the correct GI No or try another one ",0)
	RETURN
	* Similar comment as above. You should handle where 
	* the focus goes after textbox validation
ENDIF

IF USED('prodexp')
	USE IN prodexp
	* Why close PRODEXP anyway, if it gets reopen again with no changes in between?
ENDIF


SELECT 2
USE EXP!prodexp IN 0
SET ORDER TO TAG 2
SEEK lcDoc
IF FOUND()
	MESSAGEBOX("This GI No already exists try another ",0)
	RETURN
ELSE
	APPEND FROM DBF('junk2')
	* ?? Why APPEND the new data from the remote view to the table ;
	* which previous content is questionable?
ENDIF

THISFORM.expgrid.RECORDSOURCE='prodexp'
SET FILTER TO documentnumber=ALLTRIM(THISFORM.text1.VALUE)&&lcDoc
* Why not just use lcDoc here? And you should refer it consistently
* since you already used ALLTRIM(THIS.VALUE) for the same above.

* I guess here is where you get only one record, while you expect 
* to see more. 
* If your SEEK failed by whatever reason, you may even see
* the record which was in PRODEXP already, while your view may be brought nothing.

* You should to trace this method and look what's in your remote view
* and try to REQUERY it manually trying different values in your lcDoc parameter
* to see if it really works the way you want it to.
* 
GO TOP
THISFORM.expgrid.REFRESH
Anyways, I think that the data design and the workflow in this form should be changed to something more reliable.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform