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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove selection of record in a grid

Status
Not open for further replies.

keepfoxing

Programmer
Dec 9, 2015
37
PH
i have a grid on a form and when im adding
a new record, it replaces the selected record on my grid.

how to solve this issue..tnx
 
Just by the way: You have at least one control on your form using its controlsource: The grid.
A grid displays what you specify in its recordsource. Even if you don't set that it'll just grab any workarea and display it.

You should answer some questions or this won't lead to the final answer you need.

So please read back what we already asked and answer the questions.

Bye, Olaf.

 
Even if you don't set that it'll just grab any workarea and display it.

Well, it doesn't randomly pick. It will display the *current* workarea if not otherwise specified. :)
 
True, we can actually assume its the wanted workarea.

One thought, keepfoxing: You could use the class browser, open your form or form class in there and then use the view class code tool to generate code you can post here, so we see how your form is composed.

It won't help much, if the form is populated with many more things than the grid and some controls, maybe you could do a repro form with just the grid and the textbox holding the pic value and see if the behaviour is reproducable.

Bye, Olaf.

 
yes olaf.. i used append blank before i replace..
and already try that mike and the selected record replaces the pic but the added record doesnt have a pic value
i use char for the data type of pic.
 
i got it..the replace was duplicated in another control..
it was me being careless..
thanks for all your help..
 
Fine.

There had to be something else changing data, as a replace (the way you did it without REST/FOR/WHILE scope) only replaces one records field value.
Now that you're through with this bug, you should really learn how to bind controls and do with much less code.

You can do a simple data bound form just using the recordsource/rowsource and controlsource of controls and no code at all. For navigating records you use a grid, the only other thing needed is a refreh of the form, which could be done in afterrowcolchange event of the grid. Other things are optional, but good ui, eg an add/revert and savwe button. They all just need single code lines.

Doing replace was the way to work in legacy foxpro, it seems. Scatter a record to variables, let the user edit them in @GET and than gather. This is dead for at least 20 years. As you already are in Winform, move forward and slim down your codebase to maintain. Then such bugs are also a thing of the past.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top