Solved

set order of a table by two fields vfp

Posted on 2014-10-29
4
1,682 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
read data from dbf file 6 453
export vfp file to csv WITHOUT field names 2 682
FWRITE() function giving odd results 7 100
Do you know how VFP runs under Windows 8? 10 5
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…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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