Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here




Hello everyone
He has a question that was asked on more than one site, and I did not find any answer to it, and the answers were far from my question, so I will ask it here...

I want to search for a letter in a group of words and I want all words that start with this letter or in the middle or at the end of these words to appear..and this is done inside the grid.
I mean be in
thisform. column. text
I hope someone answers with this and reinforces it with an example to benefit you...
greetings to you all

RE: Grid

This is certainly possible. Let's break the problem into two parts.

First, the searching. I'll assume that your word list (the one you are searching) is stored in a table. If so, you can search it like this:

SELECT Word FROM WordList WHERE AT(Word, cLetter) > 0 INTO CURSOR csrFound

where WordList is the table, Word is the field in the table, and cLetter contains the required letter.

That will give you a cursor containing the found words.

The second step is to display the contents of the cursor in a grid.

I'll assume you already know how to place a grid on a form. Having done that, you set its RecordSourceType property to 1, and its RecordSource property to the name of the cursor (csrFound in my example). You need to do that after the cursor has been created. So put the above SELECT command in the grid's Init, followed by code to set the two properties.

There are a few other points to keep in mind, such as dealing with case sensitivity, but the above should get you started.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid

And if the word list that you are searching is in an array, you just need to copy it to a cursor first:

CODE -->

CREATE CURSOR csrFound (Word C(18))
FOR lnI = 1 TO ALEN(laWords, 1)  
  && assuming laWords is the array containing the words to be searched
  INSERT INTO csrFound (Word) VALUES (laWords(lnI))

then proceed as above.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid

Thanks for your response Mike.
Great problem analysis.
But I think there is something my friend did not know.
I would like to send you a picture showing what I want and thank you again.
Can you send me an example as in the picture and I will be grateful to you

RE: Grid

Sorry, Jawadfrhad, but I don't understand your last post. What does your screenshot represent? What is that your "friend did not know"? Do you still have a problem?


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid

The problem is that I write the code you sent me inside thisform.column2.text1
And you tell me to make
The RecordSourceType property is 1, and the RecordSource property ..
This RecordSourceType does not exist inside text1
I'm sorry and I apologize if you didn't understand me earlier and now..
Could you upload your (form.scx and form.sct) so that I can show you what I want?
I wish you success

RE: Grid


I write the code you sent me inside thisform.column2.text1

No, you shouldn't put your code there. As I said earlier, you should put the code in the Init of the grid. It's the grid that has the RecordSource and RecordSourceType properties, not a textbox or a column.

In fact, you will probably want to go further. Putting the code in the grid's Init means that you will only be doing the search once, when the form is first opened. In practice, you probably want some way of prompting the user for the letter to be searched. If so, you will need perhaps a textbox on the form (not in the grid) where the user enters the required letter, and a button to actually do the search. The code that I showed you would then go in the Click event of that button.


Could you upload your (form.scx and form.sct) so that I can show you what I want?

No, I can't do that. I haven't got a form that shows what you want. It's up to you to create your own form. I'm happy to make general suggestions for solving the problem, but I'm not going to actually create the form for you.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid

Thank you and thank you for your patience..
I will seek to find someone who solves my problem

RE: Grid


maybe, if understand the picture, you want toenter values in a grid (i never do that) coming from another table having a letter..
You may place a combobox into the grid, deleting the usual textbox which is there by default.
You will need code to fill the combobox according to user input.

If this correct ?
Then we may help on filling the combobox interactively (I myself never did that)

Or may be a class with a textbox for input and a grid showing the matches) instaed of a combobox.
We created that for a textbox which only allows entry from another table


RE: Grid

Yes, it is. But I did it and it works for me correctly. The problem with it is that it only searches for the first letter.
And if you want to download the form .. I will download it

RE: Grid

Quote (jawadfrahd)

The problem with it is that it only searches for the first letter.

Well, how do you search?

Mike told you how to locate data with the entered letter (or multiple entered letters) by using AT(fieldname, cEnteredLetters)

So if you LOCATE FOR fieldname=cEnteredLetters you have to change that to LOCATE FOR AT(fieldname, cEnteredLetters)>0
This will locate on the first record containing the entered letters.

You can then also find all records matching by iterating while records are FOUND() with CONTINUE.

In short, show what you already have, and we can try to improve it.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close