473,287 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

How to make a search engine in a form

I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?
Nov 13 '05 #1
9 20233
Christopher Koh wrote:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?


Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
.....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF


Nov 13 '05 #2
thanks salad, can you just input some explanations or input the comments
again thanks
Salad <oi*@vinegar.com> wrote in message news:<9R*******************@newsread1.news.pas.ear thlink.net>...
Christopher Koh wrote:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?


Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF

Nov 13 '05 #3
I would just like to followup, my output is in tabular form so it has
many field rows.Can you suggest what code i should write so that it
would just fill in the tab form thanks
Salad <oi*@vinegar.com> wrote in message news:<9R*******************@newsread1.news.pas.ear thlink.net>...
Christopher Koh wrote:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?


Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF

Nov 13 '05 #4
I was just wondering how come there are a lot of textfields like
me.text0,me.text1 when i only have one textfield search engine

Salad <oi*@vinegar.com> wrote in message news:<9R*******************@newsread1.news.pas.ear thlink.net>...
Christopher Koh wrote:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?


Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF

Nov 13 '05 #5
Christopher Koh wrote:
I was just wondering how come there are a lot of textfields like
me.text0,me.text1 when i only have one textfield search engine
I was descibing a method I use.

Are you refering to my use of me.Text0...1 etc? I suppose you are.

Take a look at advanced search in google.

Are you searching/filtering only on 1 field?

This is turning into a complex problem. You should know how to parse
out values in a string and you know what field you want to search.
Database tables consist of rows and columns. DO you know what you are
searching on or is it any table and any field?

Regarding a tab form. What does that mean? Does that mean your tabs
have individual subforms? Does your form have a recordsource?

If the search finds a record in some table for some field what do you
want it to do? Do you want to open a form, close a form, tell the user
a record was found, display a list of records that match?

Maybe you can tell us what you want to do besides create a google interface.

Salad <oi*@vinegar.com> wrote in message news:<9R*******************@newsread1.news.pas.ear thlink.net>...
Christopher Koh wrote:

I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?


Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF


Nov 13 '05 #6
No, i am not using a subform. My form uses the return results of a
query in a tabform in the detail section. I just found out that you
can use the binoculars on the menu to find the searched word in the
tabular form then highlights it, it also has a find next.
This was my intention. But instead of using this , I want another way
thru VB editor in which the user inputs what he wants to search on the
textbox, then he clicks on the cmdgo button to look for the word in
the tabularform then highlights it, it also has a findnext

Salad <oi*@vinegar.com> wrote in message news:<i7*****************@newsread2.news.pas.earth link.net>...
Christopher Koh wrote:
I was just wondering how come there are a lot of textfields like
me.text0,me.text1 when i only have one textfield search engine


I was descibing a method I use.

Are you refering to my use of me.Text0...1 etc? I suppose you are.

Take a look at advanced search in google.

Are you searching/filtering only on 1 field?

This is turning into a complex problem. You should know how to parse
out values in a string and you know what field you want to search.
Database tables consist of rows and columns. DO you know what you are
searching on or is it any table and any field?

Regarding a tab form. What does that mean? Does that mean your tabs
have individual subforms? Does your form have a recordsource?

If the search finds a record in some table for some field what do you
want it to do? Do you want to open a form, close a form, tell the user
a record was found, display a list of records that match?

Maybe you can tell us what you want to do besides create a google interface.

Salad <oi*@vinegar.com> wrote in message news:<9R*******************@newsread1.news.pas.ear thlink.net>...
Christopher Koh wrote:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?

Create a form with the fields for input. Have a button to start the
search and another to exit. With the search button, open up the
property sheet and create a proc in Events for the OnClick event. Then
create a filter string. Ex:

Dim strF As String
If not isnull(Me.Text0) Then strF = _
"[TableFld0] = '" & Me.Text0 & "' And "
If not isnull(Me.Text1) Then strF = strF & _
"[TableFld1] = '" & Me.Text1 & "' And "
If not isnull(Me.Text2) Then strF = strF & _
"[TableFld2] = '" & Me.Text2 & "' And "
....and etc. then remove the word And at end of filter
If strF > "" THen strF = Left(strF,len(strF)-5)

'now filter or open a form/report
Forms!FormToFilter.Form.Filter = strF
Forms!FormToFilter.Form.Filter = True

or
DOcmd.OpenReport "YourReport",,,strF

Nov 13 '05 #7
Christopher Koh wrote:
No, i am not using a subform. My form uses the return results of a
query in a tabform in the detail section. I just found out that you
can use the binoculars on the menu to find the searched word in the
tabular form then highlights it, it also has a find next.
This was my intention. But instead of using this , I want another way
thru VB editor in which the user inputs what he wants to search on the
textbox, then he clicks on the cmdgo button to look for the word in
the tabularform then highlights it, it also has a findnext


When you said "Tabular form" I thought you meant a form with tabs on them.

I have two methods I'll talk about.

I call your type of form a log form and my log forms are "continuous"
forms, not datasheet. I'm basically displaying a list of records in a
table filtered and sorted the way I want. Above each column I put a
text field in the form header. When a person enters a value in that
field above that column, I clear out any other values in the other
search fields (I use the Tag property to determine which fields to
clear). I associate each column with a field. I then create a search
string from it and store it to a public variable. When the person
presses Enter or Tab, it searches for that field. If it finds it, it
moves to that record and sets focus. If the F3 key is pressed, it
searches for the next record. It's a pretty generic form.

The second method uses a form/subform. The Main form has 2 combo
fields; a combo box and a search field. The subform is a datasheet.
When I call the form, I pass the name of the calling form. Based on the
calling form I change the recordsource of the subform. The combo box is
updated and display a list of all columns in the datasheet. The person
then selects the field to search for in the combo and enters the value
to search for. When enter or tab is pressed it searches for the record
for a matching value for the column field selected in the combo. If
found, it moves to that record.

I set the dbl-Click on the records to present single record forms for
the record found.

That's what I do/use.

Nov 13 '05 #8
Salad, i think your first method suits my intention, can you give me
the vb edit code for it so that i can study it, thanks Salad
Salad <oi*@vinegar.com> wrote in message news:<93*****************@newsread2.news.pas.earth link.net>...
Christopher Koh wrote:
No, i am not using a subform. My form uses the return results of a
query in a tabform in the detail section. I just found out that you
can use the binoculars on the menu to find the searched word in the
tabular form then highlights it, it also has a find next.
This was my intention. But instead of using this , I want another way
thru VB editor in which the user inputs what he wants to search on the
textbox, then he clicks on the cmdgo button to look for the word in
the tabularform then highlights it, it also has a findnext


When you said "Tabular form" I thought you meant a form with tabs on them.

I have two methods I'll talk about.

I call your type of form a log form and my log forms are "continuous"
forms, not datasheet. I'm basically displaying a list of records in a
table filtered and sorted the way I want. Above each column I put a
text field in the form header. When a person enters a value in that
field above that column, I clear out any other values in the other
search fields (I use the Tag property to determine which fields to
clear). I associate each column with a field. I then create a search
string from it and store it to a public variable. When the person
presses Enter or Tab, it searches for that field. If it finds it, it
moves to that record and sets focus. If the F3 key is pressed, it
searches for the next record. It's a pretty generic form.

The second method uses a form/subform. The Main form has 2 combo
fields; a combo box and a search field. The subform is a datasheet.
When I call the form, I pass the name of the calling form. Based on the
calling form I change the recordsource of the subform. The combo box is
updated and display a list of all columns in the datasheet. The person
then selects the field to search for in the combo and enters the value
to search for. When enter or tab is pressed it searches for the record
for a matching value for the column field selected in the combo. If
found, it moves to that record.

I set the dbl-Click on the records to present single record forms for
the record found.

That's what I do/use.

Nov 13 '05 #9
I wonder if the page on this link will help you. Take a look at:
http://www.utteraccess.com/forums/sh...b=5&o=&fpart=1

PC
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jlrodilla | last post by:
hi all, i´m doing a search engine using python for the spider and php to make a web for the search. The Database i have choosen is postgreSQL. Do you think it is a good choosen? Any suggestion? ...
11
by: Petre Huile | last post by:
I have designed a site for a client, but they have hired an internet marketing person to incrase their search engine ranking and traffic. He wants to put extra-large fonts on every page which will...
3
by: hazly | last post by:
I'm very new in the web technology and need advice on search engine. I want to develop a portal using PHP and MySQL on Linux. Need to know on the following features : 1. search engine that could...
4
by: MDW | last post by:
Posted this on another board, but evidently it was off-topic there...hope you folks will be able to provide some guidance. I've been working on a Web site for a business (my first non-personal...
1
by: Sheau Wei | last post by:
Below is my search engine code. I realize that the function was very limitied because i cannot searching the "NamaPealatan"(name of tools) compatible to the either categories Operasi or Balai or...
3
by: Sheau Wei | last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code? Thanks <Table cellspacing=1 cellPadding=1...
19
by: bb nicole | last post by:
Below is my search engine for job portal which jobseeker can find the job through quick search. But it cant work... Is it mysql query got problem?? Thanx.. Interface <html> <head> <title>UMS...
2
by: jamesmoore | last post by:
Hi, I have a job board and I am unsure of how to make a search form like other job boards so people can chose their needs then click search to search the posts on a webpage to then show the posts...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.