I am trying to get two files to work together. The customer file Cust with an Index on Accno and a job file Job with same index Accno. I have to admit I have not got my heard around datasources and tables as yet. I can only get the Cust file to display in the 2 dbgrids. I not sure how to get the Job details to display in the second grid. Thanks Wallace. I need 2 tables, but do I need 2 datasources? The Tablename's are set to the the correct dbase files but they both display the same info.

If you have 2 tables and want to link components to them, yes you would.

I am trying to get two files to work together. The customer file Cust with an Index on Accno and a job file Job with same index Accno. I have to admit I have not got my heard around datasources and tables as yet. I can only get the Cust file to display in the 2 dbgrids. I not sure how to get the Job details to display in the second grid. Thanks Wallace. I need 2 tables, but do I need 2 datasources? The Tablename's are set to the the correct dbase files but they both display the same info.

I recommend you stay away from tables. Rather use Queries [much more powerful] for which you also need a DTS component.

You can then program each query during RUNTIME as follows and combine the results for what you need.

You will nevertheless need PivotTABLE [see PvtTble below] in which [in this case] PNo is common to both [or more] tables.

procedure DefineWhatYouWant;
var
  qryname1,qryname2, qryname3 : string;
  s : string;

begin
  with qryYourQuery do
  begin
    if tblPvtTblePNo.value = 1 then  // 1 being whatever you set it to.
      qryname1 := '''C:YourQuery'' t1,''C:PvtTbl'' t2';
    qryname2 := ('t1.PNo = t2.PNo');
    SQL.Clear;
    SQL.Add('SELECT *');
    s:=format('FROM %s',[qryname1]);
    SQL.Add (s);
    s:=format('WHERE %s',[qryname2]);
    SQL.Add (s);
    Active := True;
  end;
end;

I have no idea why there is "smiley" in the code above above.
The line should read ''C colon PvtTbl'' t2'; at that point.

This is not a complete answer to your problem but should point you in the right direction.
The end result should be a combination of the results from one [or more] queries as above - which you combine into a DTS which serves your purpose.
I'll keep an eye on this threat in cased you need more help. Have fun!

I recommend you stay away from tables. Rather use Queries [much more powerful] for which you also need a DTS component.

Thanks for the reply. I have since gone a huge way forward since this post. What I need now :is

This is for a CNC lathe program. I have a master file (Master) that has all the operation sequences. I select operations from the Master file into a working file (Operation) to make a part.

I need to now store this new file as a separate file eg PART1.dbf

I now clear the Operation file and start a new part, PART2.dbf etc

What I need to do is store the CNC sequences (Operation) as a file which is then stored with that customers information and also be able to transfer the file/files to the CNC machine computer easily.

I already have +- 200 excel spreadsheets with past CNC sequences.

If it wasn't for the MEMO field I would probably use txt files.

Thanks Wallace

Sounds like you have half a plan.

I recommend you stay away from tables. Rather use Queries [much more powerful] for which you also need a DTS component.

Thanks for the reply. I have since gone a huge way forward since this post. What I need now :is

This is for a CNC lathe program. I have a master file (Master) that has all the operation sequences. I select operations from the Master file into a working file (Operation) to make a part.

I need to now store this new file as a separate file eg PART1.dbf

I now clear the Operation file and start a new part, PART2.dbf etc

What I need to do is store the CNC sequences (Operation) as a file which is then stored with that customers information and also be able to transfer the file/files to the CNC machine computer easily.

I already have +- 200 excel spreadsheets with past CNC sequences.

If it wasn't for the MEMO field I would probably use txt files.

Thanks Wallace

You appear to have a most intesting application and for obvious reasons you cannot go into too much detail.
Nevertheless I think I can help you but I don't think there will be enough space on this website to do so.

More particularly since clearly there are pedantic and malicious parties who subscribe to this website
who are more concerned with their own ego and "ranking" on this site [which I couldn't give two hoots
about] who tend to interfere with snide remarks and comments to one's suggestions - given in all good faith.
A poor attitude Which tends to get in the way of and interfere with intended [needed] help and of no
real use to anyone.

Over the past 49 years I have had the pleasure of being in direct [most helpful] contact with several
"ghuru's" in Delphi [Marco Cantu, Tom Swan Kent Reisdorf coming to mind] and, as my name "delphiman"
suggests, I really don't have the time or inclination to read the prattlings of some overgrown brat.
Indeed I don't think I'll be visiting this website again in a hurry.

But please feel free to contact me directly at<smail snipped> and I'll give you a detailed sulution with code.

Meanwhile you might like to give the following technique some thought. I have used it very effectively in a similar application.

It is a matter of table relationships but DON'T relate the tables using the available features in Delphi Table
and DTS components. It can can easily leave you in a corner.

Essentially you need a field in the "OperationsTbl" [say PNo] which you also have in each record in "PartsTbl".
It is then a simply matter to relate the relevant operations in the "OperationsTbl to a particular part in "PartsTbl".
Part1, Part1, Part2 [Part 1000?] then obviously and simply become records in "PartsTbl" from which this information
can then easily be retreived.

Have fun
TERRY

Marsheng,

You've described half a plan on where you're going. What you want to do. You could still arguably use a text file - if you really really wanted to, replace any line feeds from the memo field with an unused character, but it would seem a convaluted way of doing it, when Delphis DB components will do the majority of the work for you.

Its only half a plan because it sounds like theres a lot more feature planning to do before you really get going.

Im guessing that while you have a clients and a parts, and not all clients will use all the parts, so you will have some form of reference table in between that links your items together.

You need to get down on paper (or at least in a text editor) your plans, to work out what options you need, and what data you need to make those options work. At the moment you havent mentioned (at least here) how your machine can receive these controls, as well as what kinds of codes it needs - you probably I guess would need some form of human to machine conversion too, so that a little like in the days of loco (anyone else old enough to remember that?) where you would say go rt 90, fwd 100, lt 90 etc.. that this is then converted to the machine speak which of course is not readable english but perhaps binary values.

Once you have all your requirements, you will spot more of the links on how to make the bits you're currently unsure of. Design is key or you waste time redoing work later, or changing it.


Terry.

I fail to see why you take such pride and joy in calling me names. You're the one who doesnt seem able to follow the simple rules of the forum - which include not posting email address.

Im very well known in the delphi community, and, I dont feel a need to pamper to your ego which is clearly bigger than mine.

To make it simple, I would like to have the Delphi equivalent of the following DbaseIII commands.


use Operations.dbf (Opens a dbase file)
Copy to part1.dbf (Copies the entire file to a new file called Part1.dbf)
Zap (Clears the Operations file)
Append from Part2.dbf (Adds all the data from Part2.dbf into the Operations.dbf file

I am using TDBF instead of BDE.

Thanks Wallace.

Delphi doesnt have those kinds of commands, but.

Btw which version of Delphi are you using? The tDBF the one from sourceforge?

Are you intending the user to get to type use, copy to, zap etc? or just the delphi specific way of doing it with the tdbf component?

Delphi 4

tDBF from sourceforge.

The user will only have an exe, Master.dbf and Operation.dbf.

From this, the program will create for them Part1.dbf, Part 2.dbf etc

Delphi 4? ouch. THats seriously old.

OK, so, you didnt answer the last part really, or perhaps it wasnt overly clear. You speak of dbase commands like you used to code them - thats oK, Ive been there, but, are you hoping your users can type them, or just to find out how to tell delphi to do something similar?

I have 2 dbgrids on the screen. Master and Operation. The user clicks on records (CNC Tasks) in the master which adds them to the Operation file. Parameters are entered into each record in the operational file to make the part, like diameter, feed rate cutting depth etc. Once the operational file has all the operations required to make a part, (+- 10-40 records) the contents in the memo field of each record is sent through the RS232 port to the CNC machine.
The user then clicks 'Save Part as ' XXXX enters a name and the contents of the Operational file is saved to a new file named XXXX.

The user then clicks New or Load file which either clears the Operational file or clears the file and loads the new YYYY file.

Thanks Wallace

OK, so operation is more like a temporary space to write to to form a work list, to be saved later to your part1, part2?

Yes, a temporary space.

Ah, ok, sounds like you should be pretty much with most of your app by now then :)

So do you know how I do the equivalent of

Copy to
zap
and append.

Well, not having used the tdbf components I dont know what they support, but the short version would be, Id expect to do it SQL style so

select * from tablea into tableb

or

delete * from tablea

If they dont suppor that, do it the good old fashioned hardway of looping through the records

OK, If I use BDE, how do I copy a table to a new name and how do I retrieve data from another file.

see above..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.