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

validate selected check in a grid vfp 6

Status
Not open for further replies.

fanlinux90

Programmer
Oct 31, 2022
22
0
0
CO
I have configured a grid when I click on any check it changes the value of all. but I must change the validation per row, when the check in a grid has been marked only in one row, the status must be changed only for that row. can it be done in vfp6?

If thisform.Precustomers.Column1.Check1.Value = .T. and thisform.Precustomers.Column1.Check1.valid() = .T.

replace p_temp.status with 4

endif
 
Yes, this can be done. But not by testing the Value property of the checkbox. What you need to do is to check the value of the corresponding field in the underlying table or cursor.

Your Precustomers.Column1 object will have a ControlSoource which points to the field in the table or cursor to which the checkbox is bound. So, instead of [tt]IF thisform.Precustomers.Column1.Check1.Value = .T.[/tt], you need [tt]IF alias.logicalfield = .T.[/tt] , where "alias" is the alias of the table or cursor, and "logicalfield" is the name of the field in question.

Also, [tt]thisform.Precustomers.Column1.Check1.valid() = .T.[/tt] doesn't make sense. [tt]Valid[/tt] is not a property, and so cannot have a value of .T., or any other value. I'm not sure exactly what you are trying to achieve here, but this bit of code is definitely wrong.

One other point. Instead of [tt]IF alias.logicalfield = .T.[/tt], you can simply do [tt]IF alias.logicalfield[/tt]. But that's a minor point; it just makes a code a tiny bit smaller and won't affect the result.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
OK, I've been trying to understand your post. I think what you are saying is that when the user clicks a checkbox and sets its value to .T., you want to make a certain change to another field, probably in the same table (but not necessarily).

If so, then all you need is code similar to the following, in the checkbox's InteractiveChange:

Code:
IF THIS.value
  REPLACE p_temp.status with 4
  THISFORM.precustomers.SetFocus
ENDIF

If I have not understood this correctly, perhaps you could have another shot at explaining the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
fanlinux90 said:
...it changes the value of [highlight #FCE94F]all[/highlight]

The major reason you see all rows checked the same is that you didn't set the sparse property .f. to get an individually painted checkbox per row.

If you set that to .f. - the non-standard column controls like a checkbox is, are painted per row with the individual checkmarks and non-checked boxes instead of just being shown sparsely in the active row with all other rows showing the standard text1 textbox and the .t. or .f. instead of the checkmark. Notice, it's still just one checkbox control column1.check1, there is no column1.check2 nor an array of column1.check[n]. So you might not even read the value of the row you want to know it of.

To get to the individual values in a table you have exactly that, the table, its records and alias.fieldname to access it and the active row in the grid also is the active row in the table set as rowsource of the grid.

There still may be one problem you encounter anyway, that is that the moment a user clicks a checkbox and changes the control value, that's not yet stored to the controlsource field. Yyou need the valid event to happen to get there, and calling it won't help to trigger that base behaviour, because you only call the code in the valid event, maybe there's even nothing in there, then you get a .T. returned, but the value of the checkbox still is not yet transferred to the logical field of the underlying table.

Your replace code is fine, it should be in the interactivechange, I'd prefer that to the click event. It'll only replace the status field of the current record. But then you have to act only when the valu changed from unchecked to checked, right? So reacting to any click was never the right way to get to what you want to happen.




Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top