Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dumb Question # 3 Interactive Change?

Status
Not open for further replies.

FAC17

Programmer
Jan 24, 2002
26
0
0
US
First let me say thank you to those that patiently answer my questions! You make my struggles much easier!

Okay - today's question.

One form displays information from three files. Parent table stores ID # for corresponding record in child tables.

To explain my question, I'll use and example form:

Form displays customer record and related information from Sales People table and Shipping info table.

The user can select/change sales person info by selecting a name in a combo box. When the salesperson name is selected or changed the other salesperson information should be updated in the fields on the form. I thought that I should put ThisForm.Refresh() in the Interactive Change event but the information is not updateing.

Could you please help!

Thanks in advance.





 
Are you using a dataenviroment for this form with the relationships defined between the three tables? If not, did you set up the relationships after opening the tables in the form Load()? If neither of these, do you have SEEK() code in the form REFRESH() based on that ID# before a DODEFAULT?

You'll need one of these (or likely something others may suggest), as always nothing happens 'magically' - either you or you framework has to do the work.

Rick
 
The tables are opened and the relationships set in the data environment.

Is this problem related to my dumb question # 2 (if you read/responded to that one)? Ramani suggested that -to get child table data to show in a report, one has to set up the relationship (in what I consider) a backwards manner - from child to parent.

I think I may be getting a clue on this....

Is the data environment more trouble than it is worth? Would I be better off to set up the data files in what - load() or init()?

I would really like to use data environment. Seems like it was intended to take responsibility for opening files, setting indexes, and closeing same. Lessening the chances for error if this is done manually but if the durn thing is too quircky, I don't want to mess with it.

Thanks!

FAC
 
FAC,
After re-reading your first question and reviewing your response, I guess I've got a couple more questions. How are you displaying the information in tables 2 & 3? Are they in grids? What kind of recordsources are you using? If they are limited subsets based on the selected 1st table, you'll probably need to include REQUERY()s to update your recordsouces (REFRESH() doesn't do this automatically).

Note: There is nothing "wrong" with datasessions, you just have to be aware of what they provide and don't provide.

Rick
 
Mornin' Rick,

Thanks for your time!!

To answer your questions:

The form is in three sections.

Top - customer
Mid - sales person
bottom - shippping info.

Each section consist of only text boxes or combo boxes.

For example - user can pick customer with either the combo box for customer name or combo box for customer ID. Other information for selected customer is displayed in text boxes. In the middle section there are again two combo boxes for sales person name or id and then text boxes to display additional info on selected sales person. Third section same idea.

After correlating the problem to may last question (#2), I wonder if you could clarify something for me. I have been writing code for 17 years and this is how I would set up the relations for this example:

Parent table = Customer
stored in Customer table are IDs for Sales Person and
the customer id is used to find proper record in
shipping info table

Child table = Sales person indexed on sales person ID
Child table = shipping info indexed on customer ID

I would set the relations this way

select customer
set relation to salespersid into sales person table
set relation to custid into shipping info table additive

This is the way I set it up initally in the data environment. After reading your post and having a lightbulb moment about the relationships I went back and set it up this way:

A relationship FROM salesperson TO customer on salesperson ID and then a relationship FROM customer to shipping info on custid(in shipping info). And NOW it will display the proper info in the proper fields.

Can you see why the relation FROM salesperson TO customer seems backwards to me? Can you tell me why this works and the other doesn't?

Sorry this is so long. I am trying to be concise but CLEAR. Thanks again

FAC


 
FAC,
You are correct that it may seem upside down, but we are still stuck with the syntax that Ashton-Tate created for dBaseIII. Since I've been working in this xBase world for 20+ years (I worked with dBase II on a CP/M system BEFORE the IBM PC), I sometimes forget that the syntax may seem &quot;strange&quot; - I just do what I've learned works! <g>

I'm glad things are now working for you, and that at least I helped provide a &quot;lightbulb moment&quot;. Over the years I've had a number of these, and continue to find things I'd missed along the way.

Rick
 
I don't know if this will help at this stage, but here is how I would set up your form based on your initial question.

DataEnvironment: add the 3 tables. Create relation from Customer to Salesperson and from Customer to Shipping. Also, the Salesperson cursor should be set READONLY=.T.

Add 3 containers to the form, one for each table. This allows you to issue a REFRESH() to just the Salesperson container and all of the Salesperson controls will be updated.

I would then set up the Salesperson combobox. It will need to have the RecordSource set to the whole Salesperson table using RecordSourceType FIELDS or ALIAS. The ControlSource should be set to the Customer.SalespersonID field. Each of the other Salesperson fields should be bound directly to the fields in the Salesperson table. Since the cursor is read-only, they won't be able to be changed, but it can't hurt to set the controls to ReadOnly=.T. as well.

In the InteractiveChange event of the combobox, put &quot;this.parent.refresh()&quot; to refresh the container it's in and show the correct Salesperson details.

I hope I haven't confused you!

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top