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

Getting a GRID to start at a "Specific Record" in .DBF 2

Status
Not open for further replies.

cgc22

Programmer
Jan 17, 2007
10
US
HI,
I have a Mailing List .DBF file indexed by zip code. I've
created a Form with one TEXTBOX and one GRID. The textbox
is so the USER can enter the 1st "3" numbers of mailist
zip code and then the grid becomes visable to show starting
1st "3" numbers and anything else after that! Example: If I
enter "480" I want the GRID to start at all zip codes with
480 and higher. Right now the Grid only opens up showing
"all" zip codes in the right order but starting at "010"

In textbox properties I have code as follows:
INIT: zip = space(len(mlzip)) ?? mlzip is field in .DBF
VALID: seek(zip,3)

This works quite well and the textbox does properly seek
the record I want, but when I make the Grid visable it
shows "all" the zip codes from start to finish !!

I've tried "refreshing" the GRID after I "seek" the zip in textbox and the GRID still shows all zip codes. I've tried setting the "crontol source" for all textboxs (within the grid) after the seek command and it still dosen't work.

I've tried setting up a "cursor" with mailist.dbf and
create the GRID from data-environment within the Form
but that dosen't work. How can I "link" the GRID to the
TEXTBOX (SEEK) outside the grid so the Grid starts at the record I want using the SEEK command. Any help would be greatly appreciated.

Greg
 
What code do you have in the Grid INIT & REFRESH ?


David W. Grewe (Dave)
 
In textbox properties I have code as follows:
INIT: zip = space(len(mlzip)) ?? mlzip is field in .DBF
VALID: seek(zip,3)
If you make the Grid visible here in the Valid(), do the following in the Valid()
thisform.grid1.visible = .t.
thisform.grid1.refresh

Grid1 = your grid name.
this assumes you have set the recordsource and the column controlsources to the right table and fields.

 
Hi Dave & Imaginecorp.

thanks for your help to set up "specific" record so 1st
line in Grid will show that record.

Dave- no I didn't put anything in the GRID's INIT & REFRESH
but I have tried to "refresh" the grid using my textbox.valid = thisform.grid1.refresh() but nothing happens!! What should I put in the Grid's INIT & REFRESH ?

Imaginecorp - thanks for your help on putting the above
code in textbox.valid but I already tried this and the
Grid still shows all the zip codes and does not refresh itself to the "record" in .DBF file that I want the grid's first line show.

Thanks Greg

 
In the Grid Data Tab, Have you defined the source and is Bound=.t. ?


David W. Grewe (Dave)
 
see faq 184-1214 under incremental search with grids by Ramani . there are good instructions there!

My adaptation of that code uses pageframes but would be similar on a single form - places the pointer on the first record, highlights it, and leaves it there rough code as follows:


***ADD form propertys
inrecno
cfilterin
cfilterold


***textbox gotfocus
this.BackColor=RGB(255,255,204)

***testbox interactive change
LOCAL cFilterOld, cFilterIn
cFilterOld = ThisForm.cFilterOld
cFilterIn = KEY()
SEEK ALLT(This.Value)
ThisForm.Refresh()
thisform.pageframe1.searchpage.Grid1.Refresh()

***textbox lostfocus
this.BackColor=RGB(255,255,255)

***grid1 afterrowcolumnchange
LPARAMETERS nColIndex
DODEFAULT()
ThisForm.inRecNo = RECNO()
This.Columns(This.ActiveColumn).Text1.BackColor = RGB(0,255,255)
This.Refresh()
thisform.pageframe1.searchpage.txtseaRCH.SETFOCUS()

****grid1 init
DODEFAULT()
WITH THIS
.SetAll("DynamicBackColor", ;
"IIF(recno(This.RecordSource)=ThisForm.inRecno," + ;
"RGB(0,255,255),RGB(255,255,192))","COLUMN")
ENDWITH

ACTIVATE of form OR page in pageframe
SELECT ***database file**
thisform.pageframe1.searchpage.txtsearch.setfocus()
thisform.Refresh
 
Here is what I would do.
I think you can find most of this in the post by white605

Put this in the interactive change of the text box
SET EXACT OFF
SELECT MailingList
SET FILTER TO MailingList.zipcode = ALLTRIM(thisform.Text1.Value)
thisform.grid1.Refresh

I did a quick test and it seems to work ok.
Your milage may vary.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top