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

search record in cursor problem

Status
Not open for further replies.

FoxKid

MIS
Jun 8, 2003
92
0
0
IN
I am having a form with a grid having recordsourcetype as sql and recourdsource as "sele code,name,address,phone from xyz into cursor pqr"
now, I have added two combobox. Combo1 is having rowsourcetype as value and rowsource="code,name,address,phone" and combo2 is having rowsourcetype as sql and rowsource as blank
In combo2.gotfocus I have written codes as :
if .combo1.value="code"
sele code from pqr into cursor xxx order by code
endif
same for name,address,phone values.

Then I have added a command button in which I have written :
SELECT pqr
GO TOP
LOCATE FOR THIS.Parent.COMBO1.Value='"'+ALLTRIM(THIS.Parent.COMBO2.Value)+'"'
this.parent.grid1.refresh()

But the problem is that locate command searches upto last record and do not find the value i have selected (Remember I am taking data in combo2 from the same cursor having in grid)

Please help
 
hey try using DISPLAYVALUE of the combo box instead of VALUE.like :

if .combo1.displayvalue="code"
sele code from pqr into cursor xxx order by code
endif
same for name,address,phone values.

Then I have added a command button in which I have written :
SELECT pqr
GO TOP
LOCATE FOR THIS.Parent.COMBO1.DisplayValue='"'+ALLTRIM(THIS.Parent.COMBO2.DisplayValue)+'"'
this.parent.grid1.refresh()
 

If the value you are trying to locate is shown in the combobox, try using the displayvalue property of the combo rather then the value.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Again, I have done as you have suggested, but its not working
 
change your locate statement like this :
----------------------------------------------
mfield=allt(uppe(thisform.combo1.displayvalue))
mfield2=allt(uppe(thisform.combo2.displayvalue))
Do Case
case mfield="CODE"
locate for <tablename>.CODE = mfield2
case mfield=&quot;NAME&quot;
locate for <tablename>.NAME = mfield2
case mfield=&quot;ADDRESS&quot;
locate for <tablename>.ADDRESS = mfield2
case mfield=&quot;PHONE&quot;
locate for <tablename>.PHONE = mfield2
end case
 
no its not workin.
I am giving all the codes in my form, which is as follows:
I am having form with a pageframe on it name pageframe1.

thisform.pageframe1.page1.activate()
this.grid1.RecordSource=&quot;SELECT .f. as ok,buyer,buyerorder,style,shipmentda FROM .\data\alocation INTO CURSOR xselect ORDER BY buyer,buyerorder,style,shipmentda GROUP BY buyer,buyerorder,style,shipmentda readwrite&quot;
this.Refresh()



thisform.pageframe1.page1.combo1.rowsourcetype=&quot;value&quot;

thisform.pageframe1.page1.combo1.rowsource=&quot;BUYER,BUYERORDER,STYLE,SHIPMENTDA&quot;

thisform.pageframe1.page1.combo2.rowsourcetype=&quot;3-SQL&quot;




thisform.pageframe1.page1.combo2.gotfocus()
IF THIS.Parent.COMBO1.DISPLAYVALUE=&quot;BUYER&quot;
THIS.RowSource=&quot;SELE BUYER FROM xselect INTO CURSOR XBY ORDER BY BUYER GROUP BY BUYER&quot;
ENDIF
IF THIS.Parent.COMBO1.DISPLAYVALUE=&quot;BUYERORDER&quot;
THIS.RowSource=&quot;SELE BUYERORDER FROM xselect INTO CURSOR XBY ORDER BY BUYERORDER GROUP BY BUYERORDER&quot;
ENDIF
IF THIS.Parent.COMBO1.DISPLAYVALUE=&quot;STYLE&quot;
THIS.RowSource=&quot;SELE STYLE FROM xselect INTO CURSOR XBY ORDER BY STYLE GROUP BY STYLE&quot;
ENDIF
IF THIS.Parent.COMBO1.DISPLAYVALUE=&quot;SHIPMENTDA&quot;
THIS.RowSource=&quot;SELE DTOC(SHIPMENTDA) AS SHIPMENTDA FROM xselect INTO CURSOR XBY ORDER BY SHIPMENTDA GROUP BY SHIPMENTDA&quot;
ENDIF




thisform.pageframe1.command1.click
mfield=allt(uppe(this.PARENT.combo1.displayvalue))
mfield2=allt(uppe(this.PARENT.combo2.displayvalue))
Do Case
case mfield=&quot;BUYER&quot;
locate for xselect.BUYER = mfield2
case mfield=&quot;BUYERORDER&quot;
locate for xselect.BUYERORDER = mfield2
case mfield=&quot;STYLE&quot;
locate for xselect.STYLE = mfield2
case mfield=&quot;SHIPMENTDA&quot;
locate for xselect.SHIPMENTDA = CTOD(mfield2)
endcase
THIS.Parent.GRID1.setfocus
THISFORM.Refresh()



Now all the codes is with you......
 
sorry in the above codes thisform.pageframe1.page1.command1.click is like this


thisform.pageframe1.command1.click
sele xselect
go top
mfield=allt(uppe(this.PARENT.combo1.displayvalue))
mfield2=allt(uppe(this.PARENT.combo2.displayvalue))
Do Case
case mfield=&quot;BUYER&quot;
locate for xselect.BUYER = mfield2
case mfield=&quot;BUYERORDER&quot;
locate for xselect.BUYERORDER = mfield2
case mfield=&quot;STYLE&quot;
locate for xselect.STYLE = mfield2
case mfield=&quot;SHIPMENTDA&quot;
locate for xselect.SHIPMENTDA = CTOD(mfield2)
endcase
THIS.Parent.GRID1.setfocus
THISFORM.Refresh()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top