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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ms Access search

Status
Not open for further replies.

4808

Programmer
Jan 13, 2004
27
GB
Could someone help me with this code please, i am trying to do a search from three tables using a form with a comand button called search and a text box, upon entering a value to search on the result should appear on the main form. This is my attempt below:

[Dim Organisation As Object
Dim Projects As Object
Dim Provision As Object
Dim Search 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 any of the three tables,

DoCmd.ShowAllRecords
DoCmd.GoToRecord ("OrganisationID")
DoCmd.FindRecord Me!txtSearch

Organisation.SetFocus
Projects.SetFocus
Provision.SetFocus

'Organisation = Organisation
'Projects = Projects
'Provision = Provision

txtSearch.SetFocus
Search = txtSearch.Text

'If matching record found sets focus in any table
'and shows msgbox and clears search control
If Organisation Or Project Or Provision = Search Then
MsgBox "Match Found For: " & Search, , "Result!"
Organisation.SetFocus
Projects.SetFocus
Provision.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & Search & " - Please Try Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub]
 
4808,
Code:
If Organisation Or Project Or Provision = Search Then
You need to fix this line for starters.
Also, it would help if you could specify where the error(s) are occurring, so we know exactly where to look!
Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top