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

I cannt seem to populate a GRID with an SQL command

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
AU
I cannot get this to work (I am such a dunce)

What I wanted to do was search for a NAME in a TABLE.

I have a TEXT Box as a Data Entry and I wanted to use an entry format like...

LAST NAME,FIRST NAME... where the comma was the clue that the letters followed were FIRST NAME..

I have put my code below... but come what may I cannot get the data to appear in the GRID... I have changed the grid RecordSource, the RecordSourceType...

Can someone tell me where I am going wrong....

Thanks

Code:
 In TEXT1 Interactive Change - So I get immediate updates
SET CURSOR on
SELECT 1
*!*	SET ORDER to 1   && PT_EPISODE
SET ORDER TO 2   && LAST_NAME
*GO top
cLName  = ALLTRIM(thisform.text1.Value)

IF "," $ cLName
cLName1 = SUBSTR(cLname, 1, (ATC(",", cLname)-1))
cFName1 = ALLTRIM(SUBSTR(cLName, LEN(cLName1)+2, 10))  

IF LEN(cFName1)> 0

SELECT patient_episodes.Last_name, patient_episodes.first_name, patient_episodes.file_num ;
   FROM patient_episodes; 
   where patient_episodes.last_name= cLName1 and patient_episodes.first_name = cFName1;
   INTO TABLE temp.dbf;
   ORDER BY last_name
thisform.Refresh()
	  
ELSE

SELECT patient_episodes.Last_name, patient_episodes.first_name, patient_episodes.file_num ;
   FROM patient_episodes; 
   where patient_episodes.last_name= cLName1;
   INTO TABLE temp.dbf;
   ORDER BY last_name
   
thisform.grid1.visible =.t.
ENDIF


ELSE

SELECT patient_episodes.Last_name, patient_episodes.first_name, patient_episodes.file_num ;
   FROM patient_episodes; 
   where patient_episodes.last_name= cLName;
   INTO TABLE temp.dbf;
   ORDER BY last_name
   
thisform.grid1.visible =.t.
ENDIF

 
Hi Dan, Apologies... I knew that .. I was unclear in my statement..... What I MEANT TO SAY WAS that I didn't create one elsewhere. Mea Culpa.

JF
 
Nevertheless SELECT ... INTO TABLE always CREATES a table and thus asks you, if you want to overwrite. Only INSERT... INTO TABLE does insert into an existing table. SELECT ... INTO TABLE creates a table.

Therefore, what you want should not be an unsafe application, but a cursor instead of a table. INTO CURSOR temp always works, it will overwrite a cursor, if one exists, without a safety question, as cursors are meant for temp data.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top