Solved

Problem with Record Pointer!!

Posted on 1998-05-12
7
208 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now