Solved

Search ('Find' command button) on database

Posted on 1998-08-05
9
135 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

815 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

11 Experts available now in Live!

Get 1:1 Help Now