Solved

Search ('Find' command button) on database

Posted on 1998-08-05
9
133 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now