Solved

Database problem

Posted on 1998-12-10
6
173 Views
Last Modified: 2010-04-04
I'm trying to link 2 TTable with the MasterSource and MasterField properties. Everything is OK except that the order of the data in the Detail TTable is completely mixed up. I'm using Access to generate the tables. Even adding indexes doesn't help. How can I get data to display in the same order as it was originally created?
0
Comment
Question by:willemnel
[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
  • 4
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1350471
Can you give a portion of your source?

You do have set the correct indexes for your table (which delphi has to use)?

Zif.
0
 

Accepted Solution

by:
forns earned 20 total points
ID: 1350472
Hi, Willemnel.
First of all: if no "IndexFieldName" or "IndexName" is specified to order a table Delphi uses the table keys to do it. If you want the second TTable to be ordered as it was created, the only way I know is adding a field that just saves the record numbers of the records in the second table relative to the master (1st. table), so if you've got this in the 1st. table:
1 -> John
2 -> Mike
3 -> Albert
(where the first field is the person's code and the second one is his name)
and John and Albert have one phone number, but Mike's got three, the 2nd. table should be like this:
1 -> 1 -> 555-41-54
2 -> 1 -> 555-12-13
2 -> 2 -> 555-65-98
3 -> 1 -> 555-85.12
(where the first field is the person's code, the second one is a counter to indicate the phone number "code" relative to the person and the first field is the person's phone(s)).

I think I didn't explain very well, but I hope it helps.

See you!
0
 

Expert Comment

by:forns
ID: 1350473
Ooops!

Sorry, Mike's got only 2 phone numbers.
I forgot: the second table's index field should be it's second field.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:willemnel
ID: 1350474
fors - I've tried the above with no success. It STILL gives the records in random order. I have solved the problem using a TQuery with a SQL statement ("order by ... "). I'll give you points for trying. :)
0
 

Expert Comment

by:forns
ID: 1350475
Thanks much, willemnel, but I prooved my coded myself and it did work. As I told you, the only thing you've got to do is adding a field in the second table, wich contents the record number relative to the master record (from the first table).
When you add a record on the second table it should have a master in the first one, so you've got to count how many detail records has the second table at this time and add n+1 as the value of the "RelativeRecordNumber" field in the second table.

I know it is not easy to see this way, but you should try it anyway, cuz making use of TQuery much times in an app uses a lot of time and speeds down you app. performance.

I'd be glad if you tell me if you try it.

See you!
0
 

Expert Comment

by:forns
ID: 1350476
I forgot something agin!

The easiest way to solve your problem is working with just ONE table that should content the whole fields you need. That gives much better results and is the most logical way to work in 1:1 relationed tables.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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