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

Hi All! I have a listbox which use

Status
Not open for further replies.

mansii

Programmer
Oct 18, 2002
641
ID
Hi All!
I have a listbox which uses a cursor as its RowSource. I am just curious if there is another way to make it more efficient rather than putting the first statement.

Here's the codes:

thisform.list1.RowSOURCE = ""
if thisform.pageframe1.page1.check1.value = 1
select * ;
from myTable ;
WHERE SomeConditions
into Cursor myCursor
thisform.list1.RowSOURCE = "myCursor"
endif

An error message occurs if I remove the first line.

Regards
 
i have this problem myself. For moment i use a grid and it work.
sorry i canot help you with the list
 
mansii

An error message occurs if I remove the first line.

And what is the error?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Ooops.. sorry...
it says "cannot access the selected table".

Suggestion peas...
 
mansii

Try this:

Use myTable shared again in 0
thisform.list1.RowSOURCE = ""
if thisform.pageframe1.page1.check1.value = 1
select * ;
from myTable ;
WHERE SomeConditions
into Cursor myCursor
thisform.list1.RowSOURCE = "myCursor"
endif
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
That is my question, Mike.
I wonder weather there is a trick that allow me to remove the:
thisform.list1.RowSOURCE = ""
line.

BTW, what a quick response!!
Regards.

 
mansii

I wonder weather there is a trick that allow me to remove the:
thisform.list1.RowSOURCE = ""
line.


Is the rowsource of your listbox set at design time?
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
are you trying to make the listbox dynamic?

why checking for value = 1?

what are the vlaues at design time? Attitude is Everything
 
Why not put the rowsource reset inside the conditional check? i.e.:
Code:
if thisform.pageframe1.page1.check1.value = 1
   thisform.list1.RowSOURCE = ""
   select * ;
   from myTable ;
   WHERE SomeConditions
   into Cursor myCursor
   thisform.list1.RowSOURCE = "myCursor"
endif
Anytime you change a bound cursor - be it in a listbox, combobox or grid, you need to make the logical disconnect, before you reset the cursor.

Rick
 
Depending on the number of items being returned from your query, I like to use an array instead of the cursor. I create a property on the form for the array (thisform.laArray) and then run the query as such...

select * from table into array thisform.laArray

I then set the .rowsource to thisform.laArray and the .rowsourcetype to 5 (array).

Be sure to set the .boundcolumn and .boundto properties if you need to.

Ken
 
To Machele:
It's okay. ;)

To Mike:
No, the rowsource of the listbox set at run time.

To Danceman:
Yes, dynamic one. It needs to check the value of a checkbox. Does it make any different if I ommit this conditional check? Anyways, I set it to 1 at design time.

To Rick:
Actually, I put a branch using the same table. If the checkbox.value is 0, SomeConditions is different.
I thought that I can put the statement outside the conditional check. But this is not the point.

To Ken:
myTable has 5 fields. Each of the fields is source to the corresponding class. The listbox displays one of the fields.

To All:
Thank's for your quick replies.

mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top