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

Getting a "THISFORM can only be used within a method" message!!

Status
Not open for further replies.

theprophet

Programmer
Nov 2, 2000
16
US
i've got a form i created, and i use a drop down combo (in a dropdown list configuration). after i select one of the items in the list i want to filter a table based on the selection. code similiar to the following

select table
set filter to field = thisform.combobox.value

when i run the form i get the following error after i select an new item:

"THISFORM can only be used within a method"

my rowsource for the combo box is a field name and a code number and the rowsource type is "6 fields" and i'm bound to the code number (column 2 in my case).

other factors:
- data session is private
- it's modeless
- there are no relations in any of my tables in the data environment for this scenario

if anyone knows what i am doing wrong, please let me know. this thing is really getting frustrating. thanks in advance.
 
Hi

Create a form level variable.. cFilter and initialise the value to "" i.e. None

ComboBox1.LostFocusEvent
************************
ThisForm.cFilter = This.Value
SELET table
IF ALLT(ThisForm.cFilter) # ""
SET FILTER TO myField = ThisForm.cFilter
ELSE
SET FILTER TO
ENDIF

Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Actually, I've found that setting FILTERs are always a problem when it's possible the filter expression goes out of SCOPE. Try:

select table
xxx = thisform.combobox.value
set filter to field = "&xxx" && assumes character string

Of course you'll need to reset this anytime the value of the combobox changes.

Rick

 
Setting a filter to any value referring to a control value is in my opinion not a very good programming practice.

Should you wish to do this, make sure you set the filter to a value, or reference that is always present as long as the filtered table is in use.

A temporary public variable could be a solution, or a global objects' property could be a solution.

HTH,
Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top