Solved

Search ('Find' command button) on database

Posted on 1998-08-05
9
136 Views
Last Modified: 2010-05-03
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!



0
Comment
Question by:luna
  • 5
  • 4
9 Comments
 
LVL 2

Expert Comment

by:percosolator
ID: 1468057
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
 

Author Comment

by:luna
ID: 1468058
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
 
LVL 2

Expert Comment

by:percosolator
ID: 1468059
No problem with helping.

Which line does the program stop at?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:luna
ID: 1468060
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
 
LVL 2

Expert Comment

by:percosolator
ID: 1468061
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
 
LVL 2

Accepted Solution

by:
percosolator earned 50 total points
ID: 1468062
Try this:

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

BTW, it's disgusting how you are using me.... <g>
0
 

Author Comment

by:luna
ID: 1468063
I thought you guys liked being used...  THANK YOU FOR ALL OF YOUR HELP!
0
 

Author Comment

by:luna
ID: 1468064
:-}
0
 
LVL 2

Expert Comment

by:percosolator
ID: 1468065
depends.... <g>
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question