Searching In Text Box

D

dan.cawthorne

Hello All Again,

I've had a few users of mine requested a simpler search method on
going through records.

At the moment I've built querys and macros to make filters between
records on field names in my table.


So what i would like to achieve is lets say we have a table
"tbl_Projects", and it has 25 Fields then we have a form
"frm_Projects" which is bound that table, and all the fields are on
the form are bound to the field in the table. and the user can scroll
back and forwards through the records.

Though theres one or two fields with in the from "ProjectTitle" a User
Would like to start to over retype, and as they type its starts to
find (Like) matching records, with out over actually over righting the
record, So "New" Would Return 20 Project and typing "New Look" Would
Say narrow it down to 12

Can this be done is so how?

Regards

Danny
 
D

Dale Fye

Dan,

The best way to impliment this is with an unbound textboxin the forms header
or footer section.

Lets assume you create a textbox (txt_FindProjectTitle) in the forms header,
and add a command button next to it (cmd_Filter). Now the user types some
information into txt_FindProjectTitle, and in the cmd_Filter_Click event you
have some code that looks like:

Private Sub cmd_Filter_Click

IF Len(me.txt_FindProjectTitle & "") = 0 then
me.Filter = ""
me.filterOn = False
Else
me.Filter = "[ProjectTitle] like '" & me.txt_FindProjectTitle & "*'"
me.filteron = True
end if

End Sub

If you want, you could expand on this concept to include multiple textboxes
to allow searching multiple fields at once, or you could add a combo box with
the names of the fields you might want to search and let them select the
field, and then type a value into the txt_Find field. If you do this, and
you have search fields with varying data types, you will have to take that
into account in the cmd_Filter_Click event.

HTH
Dale
 
D

dan.cawthorne

Dan,

The best way to impliment this is with an unbound textboxin the forms header
or footer section.

Lets assume you create a textbox (txt_FindProjectTitle) in the forms header,
and add a command button next to it (cmd_Filter). Now the user types some
information into txt_FindProjectTitle, and in the cmd_Filter_Click event you
have some code that looks like:

Private Sub cmd_Filter_Click

IF Len(me.txt_FindProjectTitle & "") = 0 then
me.Filter = ""
me.filterOn = False
Else
me.Filter = "[ProjectTitle] like '" & me.txt_FindProjectTitle & "*'"
me.filteron = True
end if

End Sub

If you want, you could expand on this concept to include multiple textboxes
to allow searching multiple fields at once, or you could add a combo box with
the names of the fields you might want to search and let them select the
field, and then type a value into the txt_Find field. If you do this, and
you have search fields with varying data types, you will have to take that
into account in the cmd_Filter_Click event.

HTH
Dale
--
Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.

Hello All Again,
I've had a few users of mine requested a simpler search method on
going through records.
At the moment I've built querys and macros to make filters between
records on field names in my table.
So what i would like to achieve is lets say we have a table
"tbl_Projects", and it has 25 Fields then we have a form
"frm_Projects" which is bound that table, and all the fields are on
the form are bound to the field in the table. and the user can scroll
back and forwards through the records.
Though theres one or two fields with in the from "ProjectTitle" a User
Would like to start to over retype, and as they type its starts to
find (Like) matching records, with out over actually over righting the
record, So "New" Would Return 20 Project and typing "New Look" Would
Say narrow it down to 12
Can this be done is so how?

Danny

Thanks for the suggestion, i will give it a whirl, and thanks for
putting some code in for me.
 
D

dan.cawthorne

The best way to impliment this is with an unbound textboxin the forms header
or footer section.
Lets assume you create a textbox (txt_FindProjectTitle) in the forms header,
and add a command button next to it (cmd_Filter). Now the user types some
information into txt_FindProjectTitle, and in the cmd_Filter_Click event you
have some code that looks like:
Private Sub cmd_Filter_Click
IF Len(me.txt_FindProjectTitle & "") = 0 then
me.Filter = ""
me.filterOn = False
Else
me.Filter = "[ProjectTitle] like '" & me.txt_FindProjectTitle & "*'"
me.filteron = True
end if
If you want, you could expand on this concept to include multiple textboxes
to allow searching multiple fields at once, or you could add a combo box with
the names of the fields you might want to search and let them select the
field, and then type a value into the txt_Find field. If you do this, and
you have search fields with varying data types, you will have to take that
into account in the cmd_Filter_Click event.
Email address is not valid.
Please reply to newsgroup only.

Thanks for the suggestion, i will give it a whirl, and thanks for
putting some code in for me.

Dale,

If i didnt want to use a cmdfilter button, how could i get it to
filter through as i type in the unbound text box?
 
D

Dale Fye

use the textboxes Change event will refilter after each character is typed
or deleted. If you have a small dataset, that can work, but with a large
dataset, you spend way too much time waiting for the filter.

HTH
Dale

The best way to impliment this is with an unbound textboxin the forms
header
or footer section.
Lets assume you create a textbox (txt_FindProjectTitle) in the forms
header,
and add a command button next to it (cmd_Filter). Now the user types
some
information into txt_FindProjectTitle, and in the cmd_Filter_Click
event you
have some code that looks like:
Private Sub cmd_Filter_Click
IF Len(me.txt_FindProjectTitle & "") = 0 then
me.Filter = ""
me.filterOn = False
Else
me.Filter = "[ProjectTitle] like '" & me.txt_FindProjectTitle
& "*'"
me.filteron = True
end if
If you want, you could expand on this concept to include multiple
textboxes
to allow searching multiple fields at once, or you could add a combo
box with
the names of the fields you might want to search and let them select
the
field, and then type a value into the txt_Find field. If you do this,
and
you have search fields with varying data types, you will have to take
that
into account in the cmd_Filter_Click event.
Email address is not valid.
Please reply to newsgroup only.
:
Hello All Again,
I've had a few users of mine requested a simpler search method on
going through records.
At the moment I've built querys and macros to make filters between
records on field names in my table.
So what i would like to achieve is lets say we have a table
"tbl_Projects", and it has 25 Fields then we have a form
"frm_Projects" which is bound that table, and all the fields are on
the form are bound to the field in the table. and the user can scroll
back and forwards through the records.
Though theres one or two fields with in the from "ProjectTitle" a
User
Would like to start to over retype, and as they type its starts to
find (Like) matching records, with out over actually over righting
the
record, So "New" Would Return 20 Project and typing "New Look" Would
Say narrow it down to 12
Can this be done is so how?

Danny

Thanks for the suggestion, i will give it a whirl, and thanks for
putting some code in for me.

Dale,

If i didnt want to use a cmdfilter button, how could i get it to
filter through as i type in the unbound text box?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top