Ive tried the code recommended below but keep receiving a debug error. My
code is:
Private Sub Command16_Click()
Dim strPostcode As String
Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![Txtsearch]) Or (Me![Txtsearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![Txtsearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in strPostcode
DoCmd.ShowAllRecords
DoCmd.GoToControl (strPostcode) - DEBUGS HERE
DoCmd.FindRecord Me!Txtsearch
Postcode.SetFocus
strPostcode = Postcode.Text
Txtsearch.SetFocus
strSearch = Txtsearch.Text
'If matching record found sets focus in strPostcode and shows msgbox
'and clears search control
If strPostcode = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
Postcode.SetFocus
Txtsearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
Txtsearch.SetFocus
End If
End Sub
"Ofer" wrote:
> Check this link on how to create a search form, with a sample to download
>
> http://www.databasedev.co.uk/text_search.html
>
>
>
> --
> \\// Live Long and Prosper \\//
> BS"D
>
>
> "FerrariWA" wrote:
>
> > Ive read a few posts that cover this but I wanted to ask a simple way of
> > creating a search form or seach feature that will allow users to type in for
> > example, first name, last name or zip code to locate and display records in a
> > form view that match the criteria.
> >
> > The database I'm using is quite simple, contains a customer and complaints
> > table only. The complaints table is a sub form within the cutomer form. I
> > want to ceate a search form to avoid creating duplicate customer records.
> >
> > Thanks.
> >
> > Wasim