By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

search form

P: 15
hi guys. i need help on doing a search on a database. i am using ms access 2003 and the form looks like this:

http://i114.photobucket.com/albums/n258/lushh_16/searchbyclientform.jpg

when the user will type in for example "EOT Corp." in the "Search for" field and will choose "Company Name" in the "Search by" combo box, the database will look for all the "EOT Corp." entries under the field of "Company Name" in a table. does anyone have a sample VBA code for this function? thank you very much. all your replies would mean so much.
Sep 6 '06 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,634
hi guys. i need help on doing a search on a database. i am using ms access 2003 and the form looks like this:

http://i114.photobucket.com/albums/n258/lushh_16/searchbyclientform.jpg

when the user will type in for example "EOT Corp." in the "Search for" field and will choose "Company Name" in the "Search by" combo box, the database will look for all the "EOT Corp." entries under the field of "Company Name" in a table. does anyone have a sample VBA code for this function? thank you very much. all your replies would mean so much.
Assuming that you have a Form named frmClients with the underlying RecordSource of tblClients, to Find the correct Record(s) based on your Pull Downs in the Search Client Form, open frmClients in the following manner:

DoCmd.OpenForm "frmClients", acNormal, , "[Business] = '" & Me![Search for] & "' AND " & "[Name]= '" & Me![Search by] & "'", acFormEdit, acWindowNormal

Replace [Business] and [Name] with the proper Field Names and be sure
to allow for the possibility of 0 Records being returned
.

Hope this helps.....
Sep 6 '06 #2

PEB
Expert 100+
P: 1,418
PEB
Maybe you want a search engine like Yahoo and Google? To search on which word in the string expression?

And where it founds the letters from which or for other word to display the respective record?

At first place have to be the records with most analogies inside and the others...

So if you understand from VB so I'll describe the algoritme else I'll do it later...

function my_search_function(Search_string, compared) AS Integer
dim i
dim result
RESULT=0
For i = 1 to word_count(Search_string)
If instr(1,compared,get_word(Search_string,I))>0 THEN
RESULT=RESULT+1
END IF
Next i
my_search_function=RESULT
End function

Function count_word(Strings) as integer

end function

Function get_word(Strings, numb_count) As string

End function


So you have to use this function in a search query on your table

In your SQL when you do the where clause you have to put
WHERE ((my_search_function([Company], "Your search string taped here")>0);

This SQL can be generated as ADezii explained!
Sep 6 '06 #3

P: 15
thanks for the reply guys! it really did help! good day!
Sep 8 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.