Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2008

Tip: Looking for answers? Try searching our database.

Seaching using text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard - 11 Apr 2008 18:34 GMT
Hello,

Is it possible to modify the following code to search an entire table
instead of just the studentid? I have a single table named tblscanlog with 9
fields including a PK. I would use the same control names.
Thanks

Option Compare Database
'--------------------------------------------------------------
'Graham Thorpe 25-01-02
'--------------------------------------------------------------
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
Jeff Boyce - 11 Apr 2008 19:31 GMT
Richard

If you would need to "search an entire table" instead of just a single
field, that sounds like what you are looking for could be anywhere.  A
well-normalized table in a relational database (like Access) stores data so
that you'd only be looking in one field.

If you'll describe a bit more specifically what you have to work with, the
folks here in the newsgroup may be able to offer more specific suggestions.

Regards

Jeff Boyce
Microsoft Office/Access MVP

> Hello,
>
[quoted text clipped - 50 lines]
>    End If
> End Sub
Richard - 11 Apr 2008 20:08 GMT
Hi Jeff,

Sorry for the confusion, yes I would like to be able to search one "field"
in the database, but I don't know which field might want to be searched at
any given moment. They may want to search dates, purchase orders, vendors and
so on.
I don't want the search to be limited to one field like the example code.
Hope this makes sence

> Richard
>
[quoted text clipped - 65 lines]
> >    End If
> > End Sub
Jeff Boyce - 11 Apr 2008 20:57 GMT
Have you looked into using the Filter capabilities?

Regards

Jeff Boyce
Microsoft Office/Access MVP

> Hi Jeff,
>
[quoted text clipped - 79 lines]
>> >    End If
>> > End Sub
Richard - 11 Apr 2008 21:12 GMT
I'll keep looking thanks

> Have you looked into using the Filter capabilities?
>
[quoted text clipped - 86 lines]
> >> >    End If
> >> > End Sub
Evi - 13 Apr 2008 07:41 GMT
A multi-criteria search form would do this.

See the one on Allen Browne's page for an example
http://allenbrowne.com/ser-62.html

Evi

> Hi Jeff,
>
[quoted text clipped - 74 lines]
> > >    End If
> > > End Sub
Richard - 14 Apr 2008 18:18 GMT
Hi Evi,

Thanks for your responce, I took Jeffs advice and setup a filter/sort.

> A multi-criteria search form would do this.
>
[quoted text clipped - 86 lines]
> > > >    End If
> > > > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.