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

HOW TO USE CHECK BOX IN GRID CONTROL INSTEAD OF TEXT BOX

Status
Not open for further replies.

Triplex

Programmer
Oct 10, 2002
43
PH
Good Day People!!!

I have a problem regarding grid control. I use check box control instead of textbox in my control, at first theres no problem at all. But when I use an SQL statement and group my records according to employee name, the check box is no longer editable eventhough all the employee name have the same mark.

FOR EXAMPLE:

Name MARK
AAA T
AAA T
AAA T
AAA T
BBB F
BBB F
BBB F
BBB F
BBB F

when you make an SQL statement such as this:

SELECT * FROM EMPLOYEE group by MARK into cursor temp1

the result would be like this (in my grid control)

Name Mark
AAA T
BBB F

when I use temp1 as my recordsource in my grid. The value in my grid control cannot be edit unlike in the first one.

Is there a way to solve this problem?

Thanks.


 
What is the data type of the mark field? Check boxes can only be bound to logical and numeric fields. If the mark field is a character field the check box will not work.

 
Hi fluteplr!


Yes I used logical with my Mark. I can edit the Mark field in grid control only when I dont have a grouping but once I make group icould no longer edit the field (on my status bar there is a word (The control is read only.) How can I make it Read Write?

Thanks.
 
HI

SELECT * FROM EMPLOYEE group by MARK into CURSOR temp1

is only READONLY cursor. So you are not able to edit check box. Not only the check box , you wont be able to even edit names as well.

If you are using VFP7.. then.. you can code..

SELECT * FROM EMPLOYEE group by MARK ;
INTO CURSOR temp1 READWRITE

If you are using VFP6 then...

temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE
SELECT 0
USE (temp1) IN 0 ALIAS temp1
..
.. your codes and once the purpose is over..

USE IN temp1
DELETE FILE temp1+".dbf"


This should take of your needs :)



ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
HI Ramani,


Thanks for the reply. Right now I'm using VF6 I tried your code and I come up with an error "tp0wlk60.dbf does not exist". When I debug the code the value of TEMP1 = tp0wlk60 do I need to create this dbf fisrt?

Thanks Again.
 
Hi Triplex,

temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE
SELECT 0
USE (temp1) IN 0 ALIAS temp1

I think you have left out () in the SELECT statement. (temp1) should be within brackets.

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani,

Good Day. Thanks for your reply, yes your right I left out the (). But the problem right now is that an error popup says that ("Alias Name is already in use"). I put this code in load event.

temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE
SELECT 0
USE (temp1) IN 0 ALIAS temp1


and this code in unload event

USE IN temp1
DELETE FILE temp1+".dbf"

What do you think is the problem?

Thanks Again. God Bless

Triplex

 
Hi,

1. Create a form property.. cMyDBF

2. Then... where you have put the code..
temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE
SELECT 0
USE (temp1) IN 0 ALIAS temp1
ThisForm.cMyDBF = temp1

3. Destry Event
CLOSE ALL
DELETE FILE (ThisForm.cMyDBF)+".dbf"

This will solve your problem :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi,
Still the same error... When put an "set step on" the error comes when it reach the "USE (temp1) IN 0 ALIAS temp1" "Alias name is already in use".

temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE
SELECT 0
USE (temp1) IN 0 ALIAS temp1
ThisForm.cMyDBF = temp1

Thanks again

 
Try:
temp1 = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (temp1)
USE IN (TEMP1) && To make sure which table you are closing
SELECT 0 && No need for this, since you already have it next line
USE (temp1) IN 0 ALIAS temp1
ThisForm.cMyDBF = temp1

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Why aren't you just using the alias() funtion?

Using this, you would say:

* Init event
thisform.cTableName = "t"+SUBSTR(SYS(2015),4)
SELECT * FROM EMPLOYEE group by MARK INTO DBF (thisform.cTableName)
* make a form property "lwTableAlias"
thisform.lwTableAlias = alias()

select (thisform.lwTableAlias)
** put your code here **


* Destroy event
select (thisform.lwTableAlias)
use
* I suggest not to use:
* DELETE FILE (ThisForm.cTableName + ".dbf")
* because if you've selected a field which is a memo field,
* not all files are removed, so I suggest to use:
DELETE FILE (ThisForm.temp1 + ".*")


Charl
 
Dear People,

I already solved the problem. Thanks for all your help.

God Bless... Happy Halloween....


Triplex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top