Solved

set order of a table by two fields vfp

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

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…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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