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!

Search text box with button

Status
Not open for further replies.

hallm

Programmer
Jun 11, 2000
159
US
I've got a form that has several page tabs with a grid control on the first page. Right now if I click the grid control it changes the current record and refreshes my pages.

I'm wanting to add a search box on the same screen as the grid control that will find and select the current record. I've been playing around with this but I'm not having any luck.

Thanks,

Marion
 
Marion,

I believe in your case you should start with the wizardbuttons, use the wizbtns class and drop the picbtns on your form. They have also a very nice search class/button and if you are satisfied you can open the class and study for further development.

Regards,

Koen
 
I've been playing around with this but I'm not having any luck.
What techniques have you tried? If the user types a target into a textbox then a simple:

[tt]Locate For fieldname = ThisForm.txtTarget.Value[/tt]

ought to work. If you've got an index on the field then use Seek instead.

Geoff Franklin
 
I'm getting an error of Unknown member patid (Which is the name of my text box.) from the following code. I get the same on a SEEK command also.

LOCATE FOR Patient_id = ThisForm.patid.Value
THISFORM.Refresh

I tested this on a blank form with just a grid, text box, and search button and it works fine. The only difference between the form I need to build and the test form is the grid, button, and text control are all on the first page of a multipage form.

Any suggestions?

Marion
 
Hi Marion,

If patid is on a PageFrame it would be:
thisform.PageFrame1.Page1.patid.value

Regards,

Mike
 
Now I'm not getting an error but, when you search, it just scrolls to the bottom of the grid and doesn't select any records. The test form without the pages works fine.

I feel like it's close to working, just not quite yet.

Thanks,

Marion Hall
 
Hi Marion,

Sounds like your locate is failing to find a record which leaves the pointer at EOF().

UPPER(ALLTRIM(thisform.PageFrame1.Page1.patid.value))?

Regards,

Mike
 
Use the Found() function to see whether the Locate has worked:
Code:
*-- Assuming that the ID is a string
strTarget = ThisForm.PageFrame.Page1.patid.Value
LOCATE FOR Patient_id = strTarget
IF Found() Then
  THISFORM.Refresh
Else
  MessageBox("Cannot find " + strTarget)
Endif

Geoff Franklin
 
Thanks Mike the UPPER(ALLTRIM was needed. Geoff, you read my mind that was my next question. How to handle when you don't find a record.

Thanks,

Marion
 
Hi Marion,

Glad you got it working. You may want to experiment with SET NEAR ON as well. Be sure to save NEAR setting to a variable so you can restore it at the end of the routine. You can also save RECNO() so if the SEEK or LOCATE fails you can use GOTO to put the record pointer back.

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top