Add a find button to a form

M

MargieO

I am designing a contacts DB. I am quite new to access design, but I muddled
through getting together a form that is easier to use than the simple DB we
now use. I need to add a search feature/button that is easy to use (my boss
is not technically inclined) so she can find people by name, company, etc w/o
having to go record by record. Can someone walk me through what to do step by
step? Thanks.
 
O

oldblindpew

Try to find an existing Contacts database that you can use, and maybe tinker
with some minor modifications. The idea of the average person just sitting
down and developing an Access database application from scratch is pretty
far-fetched. Just look at the volume and type of questions that are being
asked in this forum. Ordinary people who are not full-time professional
developers have serious problems trying to make it work. That said, go back
and look at the thread entitled "Forms for Adding and Editing". The reply
from Allen Browne may have some helpful hints for you.
 
M

MargieO

The idea of the average person just sitting
down and developing an Access database application from scratch is pretty
far-fetched.

Far-Fetched or not, my new DB works and functions as I need it to. I just
need to add a find button to the form. I know it can be done, someone I used
to work with did it to a DB she designed (wish I still had contact with her).
Can ANYBODY help me out with step by step instructions on how to do this? I
am not a programmer yet.....I've never worked with a program that has
defeated me yet!!!
 
O

oldblindpew

Did you check out the thread I mentioned? Allen Browne describes how to use
an unbound ComboBox in you form header as a means of record navigation. You
select an entry from the drop-down list and have Access take you to that
record. More info at http://allenbrowne.com/ser-03.html

I use a Command Button (with the binoculars on it) to open a dialog form
containing a ListBox that lists all the firms in alphabetical order. The
user picks one either by double-click or by highlighting and clicking "OK"
and the record is found and displayed on the main form. My event procedure
code is:

Option Compare Database 'Use database order for string comparisons.
Option Explicit 'Requires variables be declared before use.

Private Sub cmdOkFindFirm_Click()
' Find record for main form based on selection in dialog form.

On Error GoTo Err_OkFindFirm

' Check to see if no selection was made.
If IsNull(Me!lstFirm) Then
MsgBox "Make a selection or click Cancel", , "No Selection"
GoTo Exit_OkFindFirm
End If

' Store the selection in a string variable.
Dim strSelect As String
strSelect = Me!lstFirm

' Close the dialog form to switch back to the main form.
DoCmd.Close

' Move the cursor back to the search field.
' SendKeys "+{TAB}" doesn't work, although I see no reason why it shouldn't.
DoCmd.GoToControl "txbFirmName"

' Find the selected record.
DoCmd.FindRecord strSelect

' Move the cursor back to the search button.
DoCmd.GoToControl "cmdSearchFirm"

Exit_OkFindFirm:
On Error Resume Next
Exit Sub

Err_OkFindFirm:
MsgBox "Error #: " & Err & Chr(13) & Err.Description
Resume Exit_OkFindFirm

End Sub

Your determination is commendable.
 
P

Proko

Hi Margie,
Designing your search button is quite a big job. (Not outside your scope
though) However, Access does provide a search facility built in which may be
all your boss needs to find his records. Click in the field you want to
search. Select Edit/Find from the toolbar at the top. A box opens up for you
to set your search criteria. Hope this helps.
Proko
 
T

Tom van Stiphout

On Thu, 26 Feb 2009 08:51:04 -0800, MargieO

No button needed. Just tell her she can go to ANY field and hit Ctrl+F
and get a Search box.

For the fancier lookups we have "query by form" built-in; look it up
in the Help file.

-Tom.
Microsoft Access MVP
 

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