Solved

set order of a table by two fields vfp

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

Accepted Solution

by:
pcelba earned 500 total points
Comment Utility
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
Comment Utility
Excellent as usual, pcelba!
0
 
LVL 29

Expert Comment

by:Olaf Doschke
Comment Utility
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
Comment Utility
And thanks to you, olaf. Can I start an olaf/pcelba fan club?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now