Search ('Find' command button) on database

I am currently taking a class.  My assignment was to create a program using data controls and a database.  
When the program is running, I need to have the capability to press the "Find" command button and have a search
done on the data base that I created.  Here is my example that is not working...  Please tell me what I am doing wrong.

Private Sub cmdFind_Click()
prompt$ = "Please enter the book title."
    'To do a title search
    SearchStr$ = InputBox(prompt$, "Book Search")
    datBooks.Recordset.FindFirst "Title"
    If datBooks.Recordset.NoMatch Then
        MsgBox ("Sorry buddy, your out of luck.")
        datBooks.Recordset.MoveFirst
    End If
End Sub


Thank you!



lunaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
percosolatorConnect With a Mentor Commented:
Try this:

datBooks.Recordset.FindFirst "Title = '" & SearchStr$ & "'"

BTW, it's disgusting how you are using me.... <g>
0
 
percosolatorCommented:
could you be more descriptive of what you are doing, the error messages, the table layout, error messages, results (or lack of), etc.

Is it a compile problem, run-time error, not doing what you intended....?
0
 
lunaAuthor Commented:
I am getting a 'Run Time Error 3251, Operation is not supported for this type of object.  Sorry if I am not specific enough.  I am a newbie at programming.  Thanks for your help!
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
percosolatorCommented:
No problem with helping.

Which line does the program stop at?
0
 
lunaAuthor Commented:
When I ran debug, it is getting stuck on the statement
    datBooks.Recordset.FindFirst "Title"  Maybe I don't have my variable correctly set?

0
 
percosolatorCommented:
Comments:

Private Sub cmdFind_Click()
prompt$ = "Please enter the book title."
    'To do a title search
    SearchStr$ = InputBox(prompt$, "Book Search")

                               ---Shouldn't this be "SearchStr$"? not "title"
    datBooks.Recordset.FindFirst "Title"
    If datBooks.Recordset.NoMatch Then
        MsgBox ("Sorry buddy, your out of luck.")
        datBooks.Recordset.MoveFirst
    End If
End Sub
0
 
lunaAuthor Commented:
I thought you guys liked being used...  THANK YOU FOR ALL OF YOUR HELP!
0
 
lunaAuthor Commented:
:-}
0
 
percosolatorCommented:
depends.... <g>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.