Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

set order of a table by two fields vfp

Posted on 2014-10-29
4
1,615 Views
1 Endorsement
Last Modified: 2014-10-29
Hi: ongoing purchase order system in vfp. Now creating stocksheets and I have grouped my stock codes by type.
My stocksheets print out in group order, then listed by code number. To easily key from the completed sheets  into the database I need my 'stockcount' table to mirror this exactly; sorted by type then code..
 So I need to order a table by TWO fields, not one.
I have in the button on the form that populates the  bare stockcount table at present:
"SET ORDER TO pkey ASCENDING"
 But I need to order by field 'type' first, then pkey if possible.
Have tried  "SET ORDER TO type, pkey ASCENDING"...but just knew it was going to fail.
I could run a query to create an intermediate table but what the heck; you guys are great.
And if Olaf answers, I owe you one for answering my dumb ocx question the other day.
1
Comment
Question by:ClaytonGlass
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 40410731
Ordering by more columns is possible in the SORT command and in the ORDER BY clause of the SQL query.

SET ORDER TO  requires one index tag so you have to create the index tag by expression from two columns, e.g.

INDEX ON  type+STR(pkey, 10) TAG MyOrder  && type is character, pkey is numeric here

and now you may use

SET ORDER TO TAG MyOrder
0
 

Author Closing Comment

by:ClaytonGlass
ID: 40410797
Excellent as usual, pcelba!
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40410811
that populates the  bare stockcount table
In that accessory sentence you say you have a bare (empty?) table you populate.

You can populate this way in VFP9
INSERT INTO baretable
SELECT ... FROM stockcount WHERE .. ORDER BY type, pkey

(ASCENDING is optional, only DESCENDING not.)
Once you have that report table filled report on this now not so bare table in physical record order. So no compound index is needed.

Bye, Olaf.
0
 

Author Comment

by:ClaytonGlass
ID: 40410834
And thanks to you, olaf. Can I start an olaf/pcelba fan club?
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question