hello anybody know how can i make a search button??
im having a problem on the syntax or coding i need,

i mean, for example if i put a word on a textbox(txtUN), then i click on the cmdbutton(cmdSearch)
it will retrieve all info about the data that is been put on the textbox(txtUN)

and if example, i only put a single letter ,
example i put a letter "A"

it will display 1st all data on the database which starts on a letter "A"

(is this possible?)
thx for any1 who can help me,

9 Years
Discussion Span
Last Post by hawisme000

you can make use of SQL, if you are using Database. Use "Like" clause
Ex :
select ename from emp where ename like 'A%'



And if you are using access use "*" instead of "%" ex:
select ename from emp where ename like 'A*'


To build on what the previous two posters said, you basically want to use your textbox as a variable.

So in the on_click code of your command button put something like:

Form1.recordsource = "select * from tablename where columname like '" & textbox1.value & "*';"

This will change the underlying record source of your form based on the text in your text box.

You can actually get a nice filter going with several options via combo boxes and list boxes using this technique. I've got a working sample somewhere of about 6 options to filter a query based form somewhere.

Don't forget to check to make sure there is actually a value in the text box first.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.