-
Hello
I have reviewed the Additems link and still have no idea how to update the treegrid with the cursor data i get from the sql statement i run after the badge information is entered.
Is it possible to get an example of the code required to do this. I want to list the LP.Tiem and LP.Type information in the grid.
proc page1_section1_field5_lostfocus()
// insert your code here
m_fsf="LostFocus"
close databases all
open database butchery shared
use vt_employee
select fname,lname from VT_Employee where VT_Employee.badge=m_badge into cursor emp
m_empname=alltrim(Emp.Fname)+ " "+Alltrim(EMP.Lname)
Lianja.get("Page1.section1.field7").Refresh() // EMployee Name field
TimeClockPunchUpdate()
// use vt_localpunch
// select * from VT_LocalPunch where vt_LocalPunch.Badge=m_badge and ttod(VT_LocalPunch.Datetime)=Date() into cursor LP
// select lp
// go bottom in lp
//// scatter name m_cett
// m_cett=lp.type
close database butchery
endproc
// Opon the Employee Time Clock Puch File(s) to view and update
proc TimeClockPunchUpdate()
//close databases all
//open database butchery shared
use vt_localpunch in 0
select substr(ttoc(vt_LocalPunch.datetime),12,11) as time,Type from VT_LocalPunch where vt_LocalPunch.Badge=m_badge and ttod(VT_LocalPunch.Datetime)=Date() order by datetime desc into cursor LP
m_cett=lp.type
close database butchery
////////////////////////////////////////////////////////////////
// Event delegate for 'interactivechange' event
-
I’m afraid to say that code is so incorrect in many ways that it cannot just be edited to achieve what you want to achieve. It’s wildly over complicated and requires a complete rethink.
1. using the lostfocus event is incorrect. You should be using the change event which was mentioned earlier.
2. you cannot use memory variables in a sql statement that will be executed in the VFP oledb driver as those variables do not exist in VFP
3. the additems() method of a treegrid can be used to execute a sql select statement that populates the grid.
I will put a small app together for you that does what you want and you can study it.
-
2 Attachment(s)
Install and run the attached package.
It shows you how to do it.
Attachment 3069
-
Hello
Thank you for the help. i have the grid and employee name fields updating properly now. can i extend the Fieldx.Additems Select statement to change the order in the grid ? I would also like to use the select with an additional table. When i try to sdd Order by 1 Desc i get an error.
field6.addItems("select substr(ttoc(vt_LocalPunch.datetime),12,11),;
Type from Butchery!VT_LocalPunch;
where ttod(Datetime)=Date() and Badge='"+field5.text+"'" order by 1 descending)
-
You can try and test all your sql select statements in the console.
-
Hello
I am testing the select code in the console and the order does not to change.
select datetime as Time,Type from Butchery!VT_LocalPunch where ttod(Datetime)=Date() and Badge=m_badge order by time desc
Result:
TIME TYPE
09/29/2023 09:48:15 AM 1
09/29/2023 10:50:39 AM 3
09/29/2023 10:51:44 AM 1
3 records selected in <1ms
select datetime as Time,Type from Butchery!VT_LocalPunch where ttod(Datetime)=Date() and Badge=m_badge order by time asc
Result:
TIME TYPE
09/29/2023 09:48:15 AM 1
09/29/2023 10:50:39 AM 3
09/29/2023 10:51:44 AM 1
3 records selected in 31ms
The order function works on the "TYPE" field
-
I found my mistake. All set on the Ordering of the items.
-
Hello
Is there any way to access the data in a tree grid that i fill with the following:
fields(6).addItems("select substr(ttoc(vt_LocalPunch.datetime),12,11) as Time,VT_TimeType.Label,Type from Butchery!VT_LocalPunch Inner Join Butchery!VT_TimeType on VT_LocalPunch.Type = VT_TimeType.Type where vt_LocalPunch.Badge='"+fields(5).text+"' and ttod(Datetime)=Date() order by datetime desc")
I would like to get the Type value for the top record in the grid ?
-
Use the item() method
item(nRow, nCol)
-
Hello
Is there a way to check for Lastkey() ?