Hello Everyone

Today we are discussing how to build a list of records based on the values found in a memo field. As an example, we will look at the search feature of our King James Bible Reader. The short video below shows how the Search feature works and gives an overview of the code which makes it run.


I hope you enjoyed the short video; now let’s get into the details.

As I demonstrated in the video, when the user selects Key Word Search from the Volume List the conditional object on the bottom left of the form changes the page and displays our search field, the run button and a new list object. Here is the code for the on push event of our button.

dim tbl as P

tbl = table.open("verses")
tbl.query_create("", "smatch_memo(\"Kjb_by_Verse\",\"*\"+ '"+vSearchkw+"' +\"*\")=.t.")
vList = tbl.record_content_get("vLink")
tbl.query_detach_all()
tbl.close()

if scdv = 1 then
    scdv = 0
else
    scdv = 1
end if
End

TC_KJB_Reader:cond1.Refresh()

As you can see, we are using a query to find all memo fields which have the text stored in our search variable called

‘vSearchkw’

To search the memo field we use ‘Smatch_memo’ which is an Alpha Software built-in function designed for just this purpose. The query searches each memo field and builds a record list for each record which has a match in the associated memo field returning the value stored in vLink. (Note: vLink is our field in the verses table which holds the book name, the chapter number and the verse number.) That record list is assigned to ‘vList’

vList = tbl.record_content_get(“vLink”)

which is the conditional expression used to populate our list object ‘vBooks’. Finally we only need to refresh our conditional object and our list is displayed.

Well that’s it for today. I hope you found this lesson helpful and our next couple of lessons will cover our Bookmark process and form. I hope to have it up in a few days.
Remember, if you need help with an Alpha Software application or wish to inquire about a custom application for your business go to our website

www.cdc-takecharge.com

and inquire or contact

NLawson@cdc-TakeCharge.com

Have a great day.