Solved

Problem with Record Pointer!!

Posted on 1998-05-12
7
218 Views
Last Modified: 2010-04-06
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
Comment
Question by:zahzia
[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
  • 3
  • 3
7 Comments
 

Expert Comment

by:yduke
ID: 1345097
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
 

Author Comment

by:zahzia
ID: 1345098
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
 
LVL 1

Expert Comment

by:michaue
ID: 1345099
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
Technology Partners: 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!

 

Author Comment

by:zahzia
ID: 1345100
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
 
LVL 1

Accepted Solution

by:
michaue earned 40 total points
ID: 1345101
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
 

Author Comment

by:zahzia
ID: 1345102
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
 
LVL 1

Expert Comment

by:michaue
ID: 1345103
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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