By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

Problem with Search Function in Microsoft Access

P: 1
Firstly I am using Microsoft Access 2007

I am currently trying to build a database that can search through specific lessons learnt for a company. I have started by building a table, which includes Title, Project, Date, Summary, Category, Attachments and Key Words. Next I created a split form called Lessons Learnt List, which includes the table and at the top has a button called new lesson. When this button is pushed it is linked to another form which pops up and is called Lessons Learnt Details which allows new lessons learnt to be added to the table. The save and exit button work fine. A new form was created called Lessons Learnt Search, this is where I am having the problem. I have created a text box and linked it the table and then created a button. The button has been given the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Search_Click()
  3.    If IsNull(Title) = False Then
  4.       Me.Recordset.FindFirst '[Title]=' & Title
  5.       Me!Title = Null
  6.       If Me.Recordset.NoMatch Then
  7.       MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
  8.       Me!Title = Null
  9.       End If
  11.     End If
  13. End Sub
This is displaying an error, can someone tell me where I have gone wrong? What I want in this search form is the ability to type the Title, Project, Date, Key words and Category, or just one of the following and push the search button which would bring up the results on the Lessons Learnt List Form. The format I would prefer would be

Title: (then a blank box to type)
Project: (then a blank box to type)

If there is a better way to do it, how do I do it?

Also the next thing I would like to do is have the ability in the search to type in part of a word, or just a single key word which would bring up the results? I saw somewhere this was done by using a *(and then the characters) before pushing a search button.

If not how would I do a search and list for my table, as in when I start typing the results start showing matches etc.

Thanks Very Much, Hope I was clear enough. If anything is unclear let me know!

Jun 21 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,357
Please use code tags when posting code.

1) Strings have to be surrounded by quotes, either single or double.

2) Don't forget to escape quotes in your string.

3) I certainly hope your title textbox is an unbound control. Otherwise you are replacing the actual values in your tables.

4) You use the Key Press event to call your search code. And you use the wildcards with the LIKE operator.
Jun 21 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.