PC Review


Reply
Thread Tools Rate Thread

How to create a Search Feature

 
 
=?Utf-8?B?RmVycmFyaVdB?=
Guest
Posts: n/a
 
      13th Feb 2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RmVycmFyaVdB?=
Guest
Posts: n/a
 
      14th Feb 2006
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

 
Reply With Quote
 
=?Utf-8?B?T2Zlcg==?=
Guest
Posts: n/a
 
      14th Feb 2006
What is the strPostcode?
You didn't assign a name of a field to go to

strPostcode = "Insert here the field Name in form"

Or
DoCmd.GoToControl ("FieldName InForm")


--
\\// Live Long and Prosper \\//
BS"D


"FerrariWA" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Macro with variable search feature =?Utf-8?B?cHVua3lmaXJl?= Microsoft Excel Programming 10 16th Jun 2007 08:40 PM
How do I create a macro with a variable search feature? =?Utf-8?B?cHVua3lmaXJl?= Microsoft Excel Misc 2 14th Jun 2007 07:40 PM
How do you create a search feature in a MS Word 2003 document? =?Utf-8?B?VHJpc2g=?= Microsoft Word Document Management 4 25th Apr 2006 05:50 PM
RE: How to create a Search Feature =?Utf-8?B?T2Zlcg==?= Microsoft Access 1 13th Feb 2006 08:38 PM
RE: How to create a Search Feature =?Utf-8?B?RmVycmFyaVdB?= Microsoft Access 0 13th Feb 2006 08:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:40 AM.