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!

Seek & SetFocus question?

Status
Not open for further replies.

rickbras

Programmer
Mar 16, 2000
12
US
Do the Seek and/or the SetFocus return the program flow back to the previous table? I have a two table configuration I am searching with an '...if seek(...' statement and when I search the first one all is well. When I change to the second table and do the seek I get the correct results in my grid, but when I issue a SetFocus to the grid to manipulate the data the table is automatically switched back to the first one.&nbsp;&nbsp;This, of course, plays havoc on the data in the grid.&nbsp;&nbsp;Where am I going wrong?&nbsp;&nbsp;Should I use Locate instead or is there something I am overlooking?<br>Thanks for any and all help....Rick
 
Rick, I probably have more questions than answers, but consider this:<br><br>* SetFocus is not a data command, but a UI command; it simply puts the user's focus to that control, and has nothing to do with any data manipulation.&nbsp;&nbsp;I mention this because you wrote: &quot;when I issue a SetFocus to the grid to manipulate the data&quot;<br><br>* &quot;When I change to the second table&quot;: I assume you mean using the <FONT FACE=monospace>SELECT <i>workarea</i></font> command.&nbsp;&nbsp;It <i>sounds</i> like you are changing work areas, but not changing the RecordSource property for the grid, if I correctly envision what you are doing. <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
Robert,<br>Thanks a million for your reply.&nbsp;&nbsp;You are exactly right!&nbsp;&nbsp;I finally realized (about 3 AM) I was not including the RecordSource.&nbsp;&nbsp;I had put the ControlSource in place, but overlooked the other. <br><br>If I may, I would like to ask you another puzzler.&nbsp;&nbsp;&nbsp;To leave the grid, in the last cell, I issue a SetFocus to the next control which is a text box.&nbsp;&nbsp;All works well, however, the first cell in the grid I leave gets highlighted even though it does not have the focus.&nbsp;&nbsp;It's as if the focus went to the first cell then on to the text box leaving the cell highlighted. When I turn Highlight off it still leaves the border in the first cell and moves the focus to the text box.&nbsp;&nbsp;I fear I am asking a question that has a very basic solution, but I can't seem to find it.<br><br>Thanks again,<br>Rick
 
Rick, when you say you SetFocus to the next control, a TextBox, do you mean a TextBox <u>within</u> the grid (the next cell, in other words), or outside the grid?&nbsp;&nbsp;I assume, based on the problem, that it is outside the grid.<br><br>And no, your question is not a basic one.&nbsp;&nbsp;The behaviour of whatever the grid's current cell is should be to &quot;un-highlight&quot; when the grid no longer has focus, but yours is remaining highlighted.<br><br>I'm assuming that you set focus using something like:<br><FONT FACE=monospace>thisform.txtAfterGrid.SetFocus()</font><br>correct?<br><br>Assuming all of the above, you might try a <FONT FACE=monospace>Grid.Refresh()</font>.&nbsp;&nbsp;It shouldn't be required, but to paraphrase Tom Servo:&nbsp;&nbsp;grids are like the wind; <i>nobody</i> gets them. <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
Robert,<br>Your assumptions are all correct.The text box is outside the grid and I set the focus to the text box&nbsp;&nbsp;with ThisForm.txtWriter.SetFocus(). I have refreshed everything from the form to the text box within the column of the grid with no success. Tom Servo's words are certainly true in my case. By the way, this only happens when I use the 'tab' or 'arrow' keys to exit the grid.&nbsp;&nbsp;If I use the mouse all works fine.<br><br>Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top