Search Box

  • Thread starter Thread starter arthursdomain
  • Start date Start date
A

arthursdomain

This has been posted many times, however, i havent seen any real
detailed example of this. Could anyone post an example of the exact
code needed and or an example database with a search feature in it.

Currently, what im looking to do is put a search box on my main form
(where new information is inputed), i would like to however, either do
a combo box which will drop down a list of values, which then i can
select and then the values of the form will change to the one value i
selected in the search combo box... for example

Susie 13 5'10"
Mark 18 6'1"
Josie 16 5'2"
Jill 17 5'5"

those are in the table

the form would then show one of the following, or blank, depending on
how you set up the onOPEN -- let say it opens to the first ID number
which is susie
======================
Search [ ] Go

Name: [Susie ]
Age: [13 ]
Height [5'10" ]
=======================

and of course i could adjust it if i needed to at this point. now the
search bar would be located somehwere on the form, and then when i
either enter a persons name or have combo box with their names in it
and select it. It will then move to their information

=======================
Search [Mark ] Go

Name: [Mark ]
Age: [18 ]
Height: [6'1" ]
=======================

So that now i can change his information, etc.

Z
 
so your form is bound to the table. the primary key field of the table is an
ID number, i'll call it PersonID. the PersonID field is a number data type.
you have an unbound combo box in the form's header, i'll call it cboFind.
cboFind's RowSource is the same table that the form is bound to. the
BoundColumn in cboFind is PersonID (i'm not talking about the
ControlSource - that remains empty because cboFind is an unbound control).
remember that you can set up the combo box so that it *displays* the
person's name, and you can hide the BoundColumn - but you do want the
BoundColumn to be the primary key field.

try the following code in the combo box's AfterUpdate event, as

Private Sub cboFind_AfterUpdate()

Me.Recordset.FindFirst "PersonID = " & Me!PersonID
If Not Me.Recordset.NoMatch Then
Me!PersonID.SetFocus
Me!cboFind = Null
End If

End Sub

hth
 
Back
Top