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!

How to search in a table 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
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
Untitled_pzx5sn.png



sorry for my English.
special thanks for sir mike for helping me
THANKS IN ADVANCE
 
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.
 
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:
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 [Smile]ing

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.
 
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.
 
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!
B-)

Regards

Griff
Keep [Smile]ing

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.
 
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 [tt]SELECT * FROM (cbo.Value) WHERE somecondition INTO CURSOR crsResult NOFILTER[/tt].

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: and videos
Bye, Olaf.
 
Thanks Olaf B-)

Regards

Griff
Keep [Smile]ing

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.
 
thank you guys for helping me :) I'm a fresh grad and I'm a beginner in visual foxpro take care and God bless :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top