A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

search functionality



 
 
Thread Tools Display Modes
  #1  
Old August 22nd, 2006, 04:18 PM posted to microsoft.public.access.forms
Dhaval
external usenet poster
 
Posts: 8
Default search functionality

Hi,

I have created a form to perfom data entry and modification. The current
scenario is, user has to go through all the data to find the record they
intend to edit.

However, I am looking for a functionality, where the user can enter search
string in a text box which will bring up the record(s) containg the results
and the user can then modify (do the data entry) .

Any advice will be much appreciated.

thanks

dhaval
  #2  
Old August 22nd, 2006, 04:32 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 4
Default search functionality


Dhaval wrote:
Hi,

I have created a form to perfom data entry and modification. The current
scenario is, user has to go through all the data to find the record they
intend to edit.

However, I am looking for a functionality, where the user can enter search
string in a text box which will bring up the record(s) containg the results
and the user can then modify (do the data entry) .

Any advice will be much appreciated.

thanks

dhaval


Hi,

If you are searching on one particular field then you can use the
following code...

Private Sub cmdSearch_Click()
Dim strStudentRef 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 strStudentID

DoCmd.ShowAllRecords
DoCmd.GoToControl ("strStudentID")
DoCmd.FindRecord Me!txtSearch

strStudentID.SetFocus
strStudentRef = strStudentID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control

If strStudentRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
strStudentID.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


This code is looking up a Student ID field in a database containing
student records, addresses, contact details etc.

It assumes that you have created a text box (txtSearch) and a command
button (cmdSearch).

Whatever you create, just jig about with the names in the code so that
they match the names of your text box/command button and it should work
fine!

Cheers

J

  #3  
Old August 22nd, 2006, 05:05 PM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default search functionality

Here's a few choices.

Option 1: Select the record by choosing a unique value in a combo box:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html

Option 2: Choose which field to filter on, and enter a value. The form
filters with each keystroke:
Find as you type
at:
http://allenbrowne.com/AppFindAsUType.html

Option 3: Build a search form with several search boxes where the user can
enter any combination of criteria and find matches:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dhaval" wrote in message
...

I have created a form to perfom data entry and modification. The current
scenario is, user has to go through all the data to find the record they
intend to edit.

However, I am looking for a functionality, where the user can enter search
string in a text box which will bring up the record(s) containg the
results
and the user can then modify (do the data entry) .

Any advice will be much appreciated.

thanks

dhaval



  #4  
Old August 25th, 2006, 06:47 AM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 264
Default search functionality

Filter by form doesn't work?

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.