>>>Craig - I have any question, if you don't mind.
>>>
>>>I am trying to do a search on a datafile that may yeild many records.
>>>I am using...
>>>select *;
>>>from datafile;
>>>where lastname=m_lastname'
>>>into cursor anycursor
>>>
>>>The results will go into a grid on a form.
>>>I want the user to pick the record they want
>>>and return to a main form.
>>>I have done this type of thing 10,000 times in
>>>foxpro/dos and clipper.
>>>Can you help? thanks
>>
>>Robert, are you trying to locate a individual's data information from the table into the form that you create!!
>>If so, I did it on my client program by programming a commandbutton that search through the database according to the person lastname that they enter into the textbox!! Is that what you need??
>
>Yes... but there may be many finds, that is why I thought I would use
>a grid. Inotherwords, the user my enter "Smith" and there may
>be 50 "Smith"s. In the grid, I will dispay the lastname and firstname,
>the use can pick the one they want. I need to know how to pick from
>a grid using a SQL cursor and then go back to the main form.
>Thanks Samuel...
try this code :
select
Currec = 0
if empty(ThisForm.Text4.Value)
=MessageBox("Try enter a name")
else
LOCATE FOR ALLTRIM(tablename.f_name) = ALLTRIM(ThisForm.Text4.Value)
do case
case found()
currec = recno()
goto currec
otherwise
=MessageBox("The data that you looking for is not in the database")
endcase
endif
This.Parent.Refresh()
since the problem you have is there might be 40 people with lastname Smith. All you need to do is change the code line as follows:
In order for this to work you have to create another field in the table which copy the person lastname and the firstname into one field then use the search commandbutton to search. But make sure the user input a commas and a space between lastname and firstname
Procedure putback
select tablename
scan
replace f_name with ALLTRIM(f_lname)+', '+ALLTRIM(f_fname)
endscan
LOCATE FOR ALLTRIM(