Search the DataBase in Access, Please Help

G

Guest

Hi All,

Please help me with the following:
I ahve a Access Database with one table, name - tblStaff with Coloumns
StaffID - Autonumber
Name - Text
Lastname - Text
DateOfBirth - Date
Gender - Text
Position - Text
PhoneNumber - Number
EMail - Text

I want to make a form where I'd have the possibility to seacrh the table
using Lastname or Gender or Position, as I know I must use a textbox and a
button on the form, but what kind of code or command should I use to perform
this search?

For instance I am typing the LastName of the person then click on the search
button and seeing the searched people.

Please if it's not difficult for you help me with this.
Thank you in advance

Alex
 
A

Albert D.Kallal

You could perhaps develop a complex screen, but then that is good deal of
work.

Before you go off on this quest, have you tried using the query by form
feature?

Bring up your existing form with data. Then from the main menu go

records->filter->filter by form.

The above will instantly turn your form into a VERY cool search form. Many
of the fields actually become combo boxes, and you can enter multiple
criteria.

Try the above out...as it does make a VERY cool search screen for you....
 
G

Guest

Dear Albert D. Kallal

Wow, it's the easyest way i think to perform my operations, thank you for
your timely support it really works fine and doesn't take much time (can be
done in a minute).

Thank you very much once again

If you can also tell me how it will be with the VBA Code it'll be just great

This discussion board is really helpful
 
A

Albert D.Kallal

If you are going to code a form to search, then you can try the following:

Build a unbound form. Place a text box near the top. Lets call the control
txtLastName. Turn just about everything off for hits form (record selector,
navigation buttons etc). This form is NOT attached to a table, nor any data
(we call this a un-bound form).

In addition to the above, you an build nice continues form that displays the
columns of data in a nice list. you can then put this form as a sub-form
into the above form.

Then, in the txtLastName after update event you simply stuff the results
into that sub-form.

dim strSql as string

strSql = "select * from tblCustomer where LastName like '" & me.txtLastName
& "*'"

me.MySubFormname.Form.RecordSource = strSql.

Also, in that continues form, you can place a button to launch the main edit
form. The code behind that button would be:

docmd.OpenForm "frmCustomerEdit",,,"id = " & me!id

You can see some screen shots of the above concept and code used here:

http://www.members.shaw.ca/AlbertKallal/Search/index.html

And, a have few more screens here, and in the first example, I use a listbox
in place of the sub-form.

http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm

however, in these example, you can see that you do have to write some code,
but the results are more user friendly.
 

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