PDA

View Full Version : Solved: Search Field In Access



arcanedevice
10-21-2008, 07:03 PM
Hi
I'm a complete newbie at Access, but have managed to work out most things by using my Excel / Word experience. However, I'm struggling to find out how I can create a form to 'search' a table for data and return the record in another form.
As an example, what I have set up is a form 'Search' that has one (unbound) text box 'Organisation' that the user will enter some text into, and then click on a 'Search' command button. This click will prompt a search of the 'Organisation' field within my table 'Organisations' to find matching record/s for that text.
If a match is found, then the full record is returned in another form 'Results' (or a 'No Matching Records' message is received).

While I have set the forms up, I'd really appreciate any help that people can offer on setting up the code etc to make it happen, because I need to set about 5 of these searches up (and then I've got to make them more detailed and/or searches, so the practice will be great!).

Demosthine
10-21-2008, 08:01 PM
Evening there.

Rather than trying to duplicate your Database, would you please post a sample workbook?

But in the meantime, you might check out this Microsoft Office (http://office.microsoft.com/en-us/access/HA011170771033.aspx?pid=CL100570041033) article about User Forms and Custom Searches. It may lead you to some answers.

Scott

CreganTur
10-22-2008, 05:14 AM
One way you could do this is by the DoCmd.OpenForm method- just use the value of your textbox as a part of the WHERE condition:


OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)

Your code would look something like:
DoCmd.OpenForm "FormName", , , "FieldName= '" & Me.textBox& "'"

Notice the single quotes wrapping the textbox value- this is absolutely required if the value of your textbox is a string. The method will fail otherwise.

You can use this to open a seperate form that displays the records you want to see.

HTH:thumb

OBP
10-22-2008, 02:56 PM
http://forums.techguy.org/business-applications/594085-access-2000-question-write-report.html

See post #3