Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you save a TDBAdvGrid without clicking another row?

Status
Not open for further replies.

BebopSong

Programmer
Apr 3, 2008
10
GB
Hi all,

I am currently trying to fix some code for a friend of mine and the problem is that the DBAdvGrid doesn't save when a field in one of the rows is changed. This causes some confusion as if you check one of the tick boxes and then click in another area on the screen then the box becomes unchecked again. The only way for it to stay checked is if you click another row afterwards.

I have tried setting the onKeyDown event to Edit the data and then the onKeyUp event to Post the data but if you type fast then a 'table not in edit or insert mode' error pops up. I am unsure of how to save the memberNames table when using a DBAdvGrid or even if that is what I should be trying to save.

Can anyone shed any light on how I can do this?

Regards

BebopSong
 
Sometimes the checkbox column or underlying field needs to not allow a gray state. I often will set the value of a boolean field to true or false in the TDataset.OnNewRecord event to avoid just that kind of issue.
 
My table already defaults the checkbox field to true. It's after that, if you decide to edit a field, it doesn't work. It's because when i click on a row it automatically starts editing that row and won't save until i click another row. Is there a way to save on exit that (maybe?) doesn't involve Posting?

I basically need a way to save the table after every change, i.e. checkbox click and key up, that will work for an DBAdvGrid.

To help things along my set up is:
- gridOffices: TDBAdvGrid;
- DataSource = srcOffices: TDataSource;
- DataSet = qryBuildings: TQuery;

gridOfficesHeld links to the srcOffices data source.
srcOffices links to the qryBuildings data set.
qryBuildings has an SQL statement that picks out the correct data from the database.
 
OK I have figured out how to save the checkbox when clicked. I was posting the wrong component. I needed to post the qryBuildings.

Thanks for the help though, you helped me to look at it in a different way.

Now I can relax [pipe] lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top