Solved

VFP, one-to-many write table problems

Posted on 2010-09-15
7
459 Views
Last Modified: 2012-05-10
I'm working in VFP 9.0 SP2.  I have a one-to-many program which is writting blanks fields for the many items into the one table. I have two tables:  

table "ORDERS" which holds the customer info.

table "ITEMS"  which holds the item info.

When I go to save the information I  SELECT ORDERS, find & increment the last order number and append a record with the customer data.

Then I  SELECT  ITEMS  and append the items info using this code.

IF !USED('ITEMS')
     USE ITEMS IN 0
ENDIF
SELECT ITEMS
APPEND FROM   DBF('ITEM LIST')   FOR   !EMPTY(ITEM_LIST.part_no)
SELECT 0

In the ORDERS table I am see the first row filled with the correct customer info. and I have additional rows filled with ***************** for each of the items. I was expecting to see only one row entry for each order in the ORDERS table.  It is acting like the tables are linked, but I am working with them individually.

If I have four items in an order the ORDERS table looks like this:

cust_name    |   cust_add     | cust_phone   | ......
****************|******************|*****************|........
****************|******************|*****************|  .........
****************|******************|*****************|  ..........

0
Comment
Question by:jws2bay
  • 3
  • 2
  • 2
7 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 33684563
You see such linked tables and *** for the parent records, if SET SKIP is set. As there is only one order item you only see one row filled with it other rows are filled with *** as placeholder.

Bye, Olaf.
0
 

Author Comment

by:jws2bay
ID: 33685228
Olaf

Thanks for the help
0
 
LVL 41

Expert Comment

by:pcelba
ID: 33696939
jws2bay, I don't know why you are not patient enough to wait for an answer to your question...

This is just a brief list of possibilities how to solve your one to may report problem.

You have several options one of them is to create the report for Ordered_items table and establish a relation from ordered_items to Customer. The report should have group band for Customer data and detail band for Ordered_items data:

SELECT 0
USE Customer ORDER TAG web_order
SELECT 0
USE Ordered_items ORDER TAG web_order

SET RELATION TO web_order INTO Customer

REPORT FORM YourReport ...

Another possibility is to create a query

SELECT * FROM Customer, Ordered_items ;
  WHERE Customer.web_order = Ordered_items.web_order ;
  INTO CURSOR ...

Above query creates two differently named columns for web_order. So, you probably should use a slightly modified report.

The view usage is similar to the query.

The last option could be e.g. Report Wizard which will allow to create the report in a minute including all relations.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33698946
pcelba,

an answer has already been given and accepted.

Bye, Olaf.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 33701179
Sorry Olaf, this is nothing against you and no correction to your answer. Your answer is perfect and points were assigned correctly.

My last post here was a reaction to another already deleted question...

jws2bay's speciality is to ask a question, wait one hour, and delete the question just in the time when I am working on the answer, testing it etc. I have to stop doing such mistakes...

But if the answer is already created why to put it into the trash? So, I've posted it here.

 
0
 

Author Comment

by:jws2bay
ID: 33705986
pcelba,

Sorry, I was quick on the draw.  I can understand the frustration of composing the answer and then not having the chance for it to be considered.

I had not considered putting the report together with the Customer as the group band, and the item data in the detail band. I'll have to try this out.

Thanks for the answer.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33707879
I see, haven't seen the other question at all.

I also tend to create and test samples, but lately also often keep it at pointing to the reason, often that's sufficient already.

Bye, Olaf.  
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

822 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