Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Search Field in Access form 1

Status
Not open for further replies.

bmjavakid

MIS
Jun 8, 2004
7
US
Hello,

I never do any work with Microsoft access and I was thrown into a small project using it. How do you make a search field in an access form (by the way I am using access 97)? Is there a wizard for creating such fields, or does it have to be coded?

Any and all help is very much appreciated.

Thanks!
 
In the Design View of your form, create an UNbound combobox (do not use the wizard) in the form header section.
Open the property sheet for the combobox and on the Rowsource option place a SQL statement such as the following:

Select [Itemnumber] From [tblParcel] Order By [Itemnumber];

Then on the AfterUpdate event of the combobox place VBA code like the following:

Private Sub shaid_AfterUpdate()
Dim R As DAO.Recordset
Set R = Me.RecordsetClone
R.FindFirst "[Itemnumber] = " & Chr(34) & Me![comboboxname] & Chr(34)
Me.Bookmark = R.Bookmark
Me![comboboxname] = Null
End Sub

[Itemnumber] is the name of the control on your form you want to populate.
 
hi
i assume your using a txt box and typing in your search criteria
i use access 2002 but the code should be similar

strwhere = txtsearch.text

DoCmd.OpenForm "table name", , , "[field you are searching] = (" & strwhere & ")"

hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top