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

How to set a file filter when exiting a text box??

Status
Not open for further replies.

stanmurphy

Technical User
Oct 14, 2000
89
Hello Everyone,

I have a form with 1 text box and 1 combobox. The combobox RowSource is set to a clientfile. I want to enter an initial into the text box and then set a filter on the clientfile so it only displays last names starting with that initial when I click on the ComboBox. I've placed the code below everywhere I can think of but I keep getting the error: "THISFORM Can Only Be Used Within A Method". I've changed the code to refer to the Form name, but then I get an error say it can't find the form.

SELECT Clientfile
SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1) = THISFORM.TEXT1.VALUE
GO TOP


Can someone tell me how to do this properly before I go completely insane :))

Thanks
 
Smurphy,
Place your code into the Interactive Change event of the text1 textbox, with this change:

SELECT Clientfile
SET FILTER TO
SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1) = This.Value
GO TOP

That should do it for you.

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Thanks for the reply. I tried your code and I get an error.

"THIS can only be used within a method"

 
Filter's need to be evaluated any time the record is moved, so you really need to either use a global (bad idea!) or use the actual value. In the Interactive Change event try:
Code:
SELECT Clientfile
xx = Alltrim(This.Value)
SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1) = &xx
GO TOP
Rick

 
Thank you rgbean. I tried your code but I got a message saying "variable name (whatever letter I entered) not found" each time I entered a letter. I managed to make it work with:

SELECT Clientfile
thisform.pLastInitial= ALLTRIM(UPPER(thisform.text2.Value))

store 'SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1);
= "'+thisform.pLastInitial+'"' to mdoit
&mdoit

GO TOP
 
To clarify the code above, pLastInitial is a Form Property to which I stored the contents of the text box as I exited it.
 
HI smurphy,


myForm.InitEvent
****************
PUBLIC cLastInitial
cLastInitial = SPACE(1)
This.Text1.ControlSource = m.cLastInitial
SELECT Clientfile
SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1) = This.Value
GO TOP


myForm.UnLoad
*************
RELEASE cLastInitial

This should see you thru to your form having Text1 and combo1 control you speciofied.
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
smurphy,
Ah yes, I forgot one detail:
Code:
SET FILTER TO SUBSTR(Clientfile.Clientlast,1,1) = "'"+&xx+"'"
When using string constants, it's important to Quote them!

Rick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top