Solved

How to search for phrases in Bible Access database

Posted on 2004-09-06
8
752 Views
Last Modified: 2013-12-25
I have the entire Bible stored in an Access database.  The name of the Bible books are store in text fields. The verses are stored in memo fields.  How can I quickly search all the verses for phrases and load that verse in the a richtextbox if it matches the query?

I was attempting to use the data control.
0
Comment
Question by:mcdonald_g
8 Comments
 
LVL 7

Expert Comment

by:SQL_Stu
ID: 11990135
You could use the INSTR function.

For example:

if INSTR(1, verses.text, "garden") > 0 Then

the above searches the text field within the verses table for the word "garden".  If it is found, it returns the position of the word in the text.

0
 
LVL 32

Expert Comment

by:jadedata
ID: 11990211
Greetings mcdonald_g! and Experts

 This is a duplicate question.  Answers are also being taken on http:Q_21120467.html
 mcdonald_g:  Please request a delete of this question in Community Support ("Support" at the top of the page)

regards
:)-j-
0
 
LVL 32

Expert Comment

by:jadedata
ID: 11990226
A quick re-read shows that the question are not exact duplicates.  

mcdonald_g:  You could probably have combined the questions considering they both relate to searching a specific table in your db project.

just a thought.
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11992678
You can use the like operator in SQL to filter the results to only records containing a certain verse:

e.g.
 
SELECT TableVerses.*
FROM TableVerses
WHERE TableVerses.VerseText Like '*on the first day*';

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:mcdonald_g
ID: 11993716
JR2003, can you provide all DB code for a data control do I can cut and paste?
0
 

Accepted Solution

by:
ysagada1012 earned 375 total points
ID: 11994373
JR2003,

All you have to do is save the result of the query in a recordset then transfer all its contents to your richtextbox.

i.e.

dim txtsql as string
dim txtverse as string
txtsql=SELECT Verse
FROM TableVerses
WHERE VerseText Like '*on the first day*';

rs=cn.open (txtsql)

while not rs.eof
txtverse = txtverse & rs.fields(0).value
rs.movenext
wend


0
 
LVL 18

Expert Comment

by:JR2003
ID: 11994478
A little more complete:
You will need to have a reference to "Microsoft ActiveX Data Objects 2.x Library" from the Project/References menu option.


Somewhere in a module you will have a conection object defined like this that will be connected to you database when you start your application, defined like this "Public g_MyDb As ADODB.Connection"


    Dim MySet As ADODB.Recordset
    Dim sSql As String
   
     
    sSql = "SELECT TableVerses.* "
    sSql = sSql & "FROM TableVerses "
    sSql = sSql & "WHERE TableVerses.VerseText Like '*on the first day*'"

    Set MySet = New ADODB.Recordset
       
    With MySet
        .Open sSql, g_MyDb
        While Not .EOF
            RichTextBox1.Text = RichTextBox1.Text & !VerseText
            'Add record processing code here
            .MoveNext
        Wend
        .Close
    End With
    Set MySet = Nothing


0
 

Expert Comment

by:DarrelW
ID: 23565987
I have a similar case, but the verses are stored in RTF-encoded format. I can read the data as text, but it will not recognize the RTF codes, so I think I am pulling the data from Access as text rather than rtf.

I connect fine to the Access db. I can read any straight text verses fine, only bombs when reading RTF.

Can you help me?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 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

13 Experts available now in Live!

Get 1:1 Help Now