INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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.

Jobs

How to search in a table

How to search in a table

hi sir/ma'am,
its me again purpleface i have question how to search in 4 table?
for example in combo box I have 4 items ('A', 'B', 'C', 'D')
each letter have table if i select 'A' in the combo box.
if i will search the data inside the table of 'A' What I can find is just inside the table of 'A'

to clarify



sorry for my English.
special thanks for sir mike for helping me
THANKS IN ADVANCE

RE: How to search in a table

Please change your profile, and use a name close to your real one. I am not inspired to help people who hide themselves behind a mask.

RE: How to search in a table

(OP)
updated done :) thanks sir

RE: How to search in a table

What is this interest in profile names? It's not a requirement of Tek-Tips as far as I know.

Anyway, Ralph, or whatever, asks a fair question.

You need some code in the interactivechange event (other events may also be helpful) that reads the current value of the combobox and searches the appropriate table based on that:

CODE --> MySearch.InteractiveChange

IF !EMPTY(this.value)
	IF !EMPTY(thisform.MyComboBox.Value)
		DO Case
			CASE thisform.MyComboBox.Value = "A"
				SELECT MyTableA
			CASE thisform.MyComboBox.Value = "B"
				SELECT MyTableB
			CASE thisform.MyComboBox.Value = "C"
				SELECT MyTableC
			CASE thisform.MyComboBox.Value = "D"
				SELECT MyTableD
		ENDCASE
		LOCATE FOR THIS.VALUE$MyFieldBeingSearched
		IF !FOUND
			MESSAGEBOX("Not Found ["+THIS.VALUE+"]",48,"Oh Dear")
		ELSE
			&& do something to show the success
		ENDIF
	ELSE
		MESSAGEBOX("Please Select a Table from the List",48,"Problem")
		THISFORM.MyComboBox.Setfocus()
	ENDIF
ENDIF 

Just a rough and ready start, no attempt at optimisation or cleverness, just an idea.

Think about programmaticchange, gotfocus, lostfocus as well.


Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to search in a table

Griff, my interest in profile names is not related to any restrictions on this site. It's just like I wrote, I want to have some sort of feeling of whom I help. If someone hides behind a mask by using a totally meaningless pseudonym, I don't feel any motivation to help. Or to use other words, I feel much more motivated to help JohnA or LisaB than I feel for helping PleaseHelpMe or Troll2.

RE: How to search in a table

Only snag with that is, you've let the cat out of the bag now... all the trolls will know not to use Troll2 as a handle!
happy shades

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to search in a table

I think it is much more important HOW questions are asked...

RE: How to search in a table

Griff's code is ok, it could be made better, for example, if your combo box values simply were the alias names used for the tables you wouldn't need the CASE statements, simply SELECT (cbo.VALUE) on the condition USED(cbo.VALUE).

Griffs Code has one prerequisite, that the tables you search already are open (USED), for example by being put into the data environment of a form or by USE statements in the form load or init. You could already have them open to display them already before searching, but you might also want to open a table at the time it is really searched.

Then you may want to do a SQL query based on the search term, which does not only locate one first result record. That means LOCATE is not the only and surely not the best way to search a table, though it is a simple approach, it might not be as highly optimised as SQL can be. With SQL you also wouldn't need to do the preparation step to open a table, the SQL statement can do that simply based on the file or table name, eg SELECT * FROM (cbo.Value) WHERE somecondition INTO CURSOR crsResult NOFILTER.

It's too undefined, what you want to have, so this may hold as a first solution approach, but it's not the only way.

You ask for very basic things and seems to have not much programming experience, that's why I would conclude this way: Don't think you can learn VFP programming by solving simple tasks, that's asking for detail solutions to problems you wouldn't even have, if you had a foundation of knowledge about how to do things in VFP on a much more general level than how to use each single function or command.

Learn a few basics, watch some resources like the solutions.app coming with VFP, which you find opening the task pane and clicking on Solution Samples. Then there are books: http://fox.wikis.com/wc.dll?Wiki~GoodVFPBooks and videos http://fox.wikis.com/wc.dll?Wiki~VFPVideos~Wiki

Bye, Olaf.

RE: How to search in a table

Thanks Olaf happy shades

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: How to search in a table

(OP)
thank you guys for helping me :) I'm a fresh grad and I'm a beginner in visual foxpro take care and God bless :)

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!

Resources

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