Solved

Syntax for entering a value into a variable fieldname using Delphi 5 dbgrid

Posted on 2011-03-12
2
597 Views
Last Modified: 2012-05-11
The problem. I have a popup calculator that I use to calculate the value to enter into a dbgrid. It works well for a specified field but I want it to work for any field identified by the column fieldname.

Eg:
field_name_variable := dbgrid.fieldname (for the current column)
value_variable := [some calculated result from the popup calculator]
tablename.field_name_variable.value := value_variable.

I do not know the syntax for assigning the fieldname from the field_name_variable.
0
Comment
Question by:THiggins73
2 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 35118940
Use fieldbyname
field_name_variable := dbgrid.fieldname (for the current column)
value_variable := [some calculated result from the popup calculator]

tablename.edit;
tablename.FieldByName(field_name_variable).Value := value_variable.
tablename.post;

Open in new window

0
 

Author Closing Comment

by:THiggins73
ID: 35143799
Thank you for your prompt response.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

12 Experts available now in Live!

Get 1:1 Help Now