Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Populate data thru query in list box
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00663425
Message ID:
00663446
Views:
15
This message has been marked as the solution to the initial question of the thread.
>I am using a list box where i want to display the records using the following query.
>Only the matching records need to appear in the list box.
>
>Can you please advice me how to show the records in the list box.
>
>
>SELECT * FROM sub WHERE sub.project_no = this.project_no.value
>AND sub.workpkg_no = this.workpkg_no.value
>AND DELETED() = .f. ORDER BY project_no, workpkg_no
>
>
>
>For list box i writing this code.
>
>WITH thisform.list1
>
> .RowSourceType = 0
> .RowSource = "sub.project_no,workpkg_no,sub_sec,sub_para,sub_seq,sub_title"
> .RowSourceType = 6
> .refresh()
> .setfocus()
>ENDWITH
>
>
>
>Thank you Very much.

You just need
lcSource = "SELECT project_no,workpkg_no,sub_sec,sub_para,sub_seq,sub_title ;
FROM sub ;
WHERE sub.project_no = this.project_no.value ;
AND sub.workpkg_no = this.workpkg_no.value ;
AND DELETED() = .f. ;
ORDER BY project_no, workpkg_no ;
into cursor cSource"

WITH thisform.list1
	.RowSourceType = 3 && SQL Statement
	.RowSource = lcSource
	.Requery()
	.refresh()
	.setfocus()
ENDWITH
Make sure that this.project_no.value and this.workpkg_no.value are in scope. You might want to place these values into the form properties ant refer to them.
You might not need the condition
DELETED() = .f. (or in another form !DELETED() )
if you have SET DELETED ON

When the data in SUB table change, you will need to issue
thisform.list1.Requery()
thisform.list1.Refresh()
to refresh the content of the listbox.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform