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!

grid shows last selected row

Status
Not open for further replies.

fanlinux90

Programmer
Oct 31, 2022
22
CO
In the form I first click on the approve button and then on the pending button. in a form add a button to show the records with state 0. I use version 6 of visual fox pro.

button approved procedure click

select f_temp
go top
scan
If f_temp.apprvd = .T.
select f_temp
replace f_temp.estado with 4 for empty(f_temp.desc_obj)

SELECT f_temp
for ve = 1 to reccount()
select f_temp
go ve
If f_temp.apprvd = .T.
update Pr set pr.estate = f_temp.state where pr.doc = f_temp.doc
endif
endfor

endif
endscan

select f_temp
go top
scan
If f_temp.aprobado = .T.
select f_temp
replace f_temp.estado with 5 for !empty(f_temp.desc_obj)

SELECT f_temp
for ve = 1 to reccount()
select f_temp
go ve
If f_temp.apprvd = .T.
update Pr set pr.estate = f_temp.state where pr.doc = f_temp.doc
endif
endfor

endif
endscan

select f_temp
go top

Thisform.pr.RecordSource = ""
Thisform.pr.RecordSource = "f_temp"

with thisform.pr
.recordsource = .recordsource
endwith

Thisform.pr.column1.ControlSource = "f_temp.lastn"
Thisform.pr.column2.ControlSource = "f_temp.lastn"
Thisform.pr.column3.ControlSource = "f_temp.mname"
Thisform.pr.column4.ControlSource = "f_temp.name"
Thisform.pr.column5.ControlSource = "f_temp.phone"
Thisform.pr.column6.ControlSource = "f_temp.state"
Thisform.pr.column7.ControlSource = "f_temp.obs"
Thisform.pr.column8.ControlSource = "f_temp.apprvd"

thisform.pr.setfocus()
Thisform.pr.refresh
thisform.refresh



button pending procedure click

select doc, lastn, mname, name, phone, state,obs, apprvd;
from f_temp ;
where f_temp.state = 0 into cursor f_temp2

select f_temp2
go top

Thisform.pr.RecordSource = "f_temp2"

with thisform.pr
.recordsource = .recordsource
endwith

Thisform.pr.column1.ControlSource = "f_temp2.lastn"
Thisform.pr.column2.ControlSource = "f_temp2.lastn"
Thisform.pr.column3.ControlSource = "f_temp2.mname"
Thisform.pr.column4.ControlSource = "f_temp2.name"
Thisform.pr.column5.ControlSource = "f_temp2.phone"
Thisform.pr.column6.ControlSource = "f_temp2.state"
Thisform.pr.column7.ControlSource = "f_temp2.obs"
Thisform.pr.column8.ControlSource = "f_temp2.apprvd"

thisform.pr.setfocus()
Thisform.pr.refresh
thisform.refresh

Only show the last record selected from the grid, how do I make it show all the records with state 0?
 
I noticed that you haven't had any replies to this question, nor to your thread184-1825069.

I suggest that you are more likely to get a helpful response if you explain more clearly what you are trying to achieve. In both of these cases, you have posted a large chunk of code with no explanation of what it is meant to do. You can't expect us to study the code and to try to figure out what is going wrong. Nor does it help to start two different threads both dealing with the same problem. That just gives us more work.

Also, when posting large code, it is really helpful to use the [ignore]
Code:
[/ignore] tags, which you can enter either manually or from the "code" button on the toolbar. This will cause the code to be properly formatted, in particular with indentations, all of which make it easier for the code to be understood.

Please keep these points in mind. That way, we are more likely to be able to help you.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
fanlinux said:
how do I make it show all the records with state 0?
This question is stating your problem, you should begin our post with describing the problem, then going into details.

Your post actually isn't far off of being all we need to reproduce the problem and fix it. But we don't have your data available, so all that code doesn't help to reproduce and even see the problem.

What I can see is that the query where clause is correct:
Code:
...where f_temp.state = 0

You fetch all records with state=0. You also go top, though a select into cursor will create f_temp2 with the current record pointer being at its top, unnecessary.

I can only conclude if you only see one record in this result, there also is only one record with status=0 and the problem here is not grid behavior or bugs, but your expectation of data, simply browse f_temp and see for yourself, SQL won't fail to fetch multiple records into ftemp2 if there are multiple with f_temp.state = 0, there is no SQL bug.

So I guess the problem is somewhere else setting only one record's state to 0 when you expect to accumulate multiple records with state=0 somehow.

If you can't make up a code example including the necessary code to produce sample data, like you see when you even just look into answers of MarK in this forum, then it's hardly realistic you can get help here.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top