Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Quick Search Macro"

Quick Search Macro

A quick way of using Cardbox's powerful search capabilities.

Current user: [none]
Register / Log In · Help

Posted By Post

Jelly Belly

25-Feb-2010 17:07

Firstly before somebody says "Cardbox already does this!", this Macro I believe, enhances the search function of Cardbox and is now used as a preference by our company. Maybe it might help you? Basically playing the Macro (mine is linked to a button) will bring up an Input box for your search. If you enter a word Cardbox will search all fields and has a wildcard at the end for example "JOHN*". If you leave a space and enter a second search Cardbox will automatically search again for the second item. for example "JOHN* PORTSMOUTH*" will find every instance of John living in Portsmouth. If no results are found a message box will appear and automatically take you back a level so all the Johns are found. You can enter up to 4 search parameters in one search. Obviously this will not suit every application and the normal select methods can be used.

The Code.....

Dim Qsearch,Word,NewSearch
On Error Resume Next

SelectionLevel=0

Qsearch = InputBox ("Enter Your Search","Quick search")

If Qsearch = "" Then Halt

Word = Split (Qsearch)

ActiveWindow.Select "",(Word(0)) & "*"
Sleep 10
ActiveWindow.Select "",(Word(1)) & "*"
Sleep 10
ActiveWindow.Select "",(Word(2)) & "*"
Sleep 10
ActiveWindow.Select "",(Word(3)) & "*"

If RecordCount = 0 and SelectionLevel = 4 Then
MsgBox "No Matching Records Found!",64,"Quick Search for...'" & (Word(3)) & "'"
UndoOneSelectionLevel
End If

If RecordCount = 0 and SelectionLevel = 3 Then
MsgBox "No Matching Records Found!",64,"Quick Search for...'" & (Word(2)) & "'"
UndoOneSelectionLevel
End If

If RecordCount = 0 and SelectionLevel = 2 Then
MsgBox "No Matching Records Found!",64,"Quick Search for...'" & (Word(1)) & "'"
UndoOneSelectionLevel
End If

If RecordCount = 0 and SelectionLevel = 1 Then
MsgBox "No Matching Records Found!",64,"Quick Search for...'" & (Word(0)) & "'"
UndoOneSelectionLevel
End If

bert

25-Feb-2010 23:46

It is also my experience that adding that type of things for many people (and me) Cardbox becomes more easy.

Why so less people has discovered it yet?

Regards
Bert

Llewellyn

17-Jun-2015 02:33

Firstly thanks for this macro!
Secondly = Newbie.

When I use the above macro as is, I always come up empty handed - I believe this may have to do with the way my database is set up. When I do a manual search, I also come up empty handed when I don't specifically Select "search record data" as the default is "search the database index".

Any idea's as to where I can set "search record data" in the above code? Or when I can read up on this?

Any pointers much appreciated.

Thanks

bert

17-Jun-2015 12:07

It seems your database fields not have the property activated 'index automatic' or 'all'.
If you type text then, all field content is not indexed. Hard to search for Cardbox in the index while there is nothing.
So change the properties - I advise 'all' except there are special reasons to do it different - , then use function adjust indexing.
Btw: if you had read the free manual then you had read how to setup a database and to avoid this...
Regards
Bert

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home