[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Problem with Record Pointer!!

Hi,
I am new in delphi and working in Delphi 3.0 with local database (PARADOX) I just want to tell you about the structure of tables ....I have three tables actually...like

**PRODUCTS**
ProductCode   Alpha   4          *  <---(its my Key Field)
Description      Alpha   30
Qty_onhand     Integer

** Master_Table **
ProductCode   Alpha  4    *  (Key Field)
MDate              Date

** Detail_Table **
ProductCode    Alpha  4    * (Key Field)
Description       <-----(its my Lookup field in Detail Grid and picked from Products Table)
Qtytoproduced  Integer

So as you can see Products is my Lookup Table...and the problem is in TDBGrid when I Insert
Record and give a Product Code it automatically Pick the Description from Products Table and then I give
Qtytoproduced and this Quantity I want to add in Products Table...But I think that After Picking-up the Description
from Products table Pointer has to be located at the position of given valid Product Code But it always at the First Record in Products Table and thats Why I am feeling a trouble to add the QtytoProduced in the Products Table Coz if the Record Pointer is not automatically located there then Its hard for me to writing the long code for addition of those Quantities in Products Table....
So please kindly repyl me if anybody can answer my question Coz I am working on a project and time is the only matter for me ...

thanks
Zahid
0
zahzia
Asked:
zahzia
  • 3
  • 3
1 Solution
 
ydukeCommented:
Hi Zahid,

Although in your description of your problem you were not very clear on the table names, from what I understand a solution for you is to use SQL statement to locate the appropriate record and point the pointer where you want.  

After you insert the product code and you perform a lookup to get the description from products table, write an SQL statement for the Detail_Table using the product code value stored in your form's edit.box for product code.  Then set as parameters in your SQL statement the Qtytoproduce field and store it in a hidden edit box.  Then just write a line of PASCAL code adding that variable with the Qtytoproduce.box (the entered value in the form) and then call the update function to update the table.  Make sure that you have "cash updates" enabled on the tables parameters, and also that you open and close the tables every time you use them(using the functions, open/close/update etc).

good luck

0
 
zahziaAuthor Commented:
Actually you misunderstand my Question I just want to know that in LOOKUP field is this true that record pointer has to be located at the position in the lookup table of the searching code or not ? Or one has to be located that pointer explicitly ...??
thats it...

0
 
michaueCommented:
Am I right in assuming that you want to move Qtytoproduced from the Detail Table to the Qty_onhand field in the Products Table, where the Product Code from the Detail Table match up with the correct record to update in the Products table (where the Product codes is the same)?

And am I correct in assuming that when you want to update the Products table the record pointer is at the first record, therefor your update isn't correct?

If this is the case, I will be able to answer your question.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
zahziaAuthor Commented:
Yes now you got my question correctly....this is the problems I am facing right now...
In my product table there are three products records actually..Like

ProductCode  Description      Qty_onhand
0001              ABC product       100
0002              DEF product        200
0003              GHI  product        300

So in detail table GRID let suppose I give 0002 and then it picks the description
'DEF product' from the PRODUCTS table and then I want to add 450 in the previous balance of products table which is 200 ....but then after posting the record it always add that 450 at the first record of the products table which is 0001 ABC product and it adds the 450 into 100 which is the balance of 0001 product....so thats my problem...
Why the pointer of PRODUCT table is still on first record ...but strange thing is the lookup is perfect but after successful lookup it leaves the pointer at the begining...
So now what would you like to say....

thanks

0
 
michaueCommented:
You can move to a specific record in the PRODUCTS table by using the following command. You can set its paramaters to do many different things.  Have a look in help if you want to know more ...  The basic idea is the following :

if PRODUCTS.locate('PRODUCTCODE','0002',[]) = true then
  <Update the record>

The locate method will position the counter on the field. You can find more help on it under TBDEDataSet.Locate.
0
 
zahziaAuthor Commented:
My question is still in middle coz i just want to know that in my situatuion pointer has to be move or not thats it ?
and I solved my problem already to move my record position throuch locate but I just want to ask that its normal or not ?

0
 
michaueCommented:
No as far as I have experienced the record pointer doesn't move when you do a lookup on a table like that, because in most transactions when a lookup table is referenced thats all that happens, and the lookup table isn't updated in the same procedure step.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now