?
Solved

set order of a table by two fields vfp

Posted on 2014-10-29
4
Medium Priority
?
1,992 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
[X]
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
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

777 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