data searching functionality is necessary in every business application. and we need to provide a fast and easy option to end-user to select appropriate record from big tables like product list, invoice list etc.
here is a framework class to create look-up forms for your applications. its very simple one. i created it for my applications and found very useful.
i would like to share it with you. i am sure it will save your time from creating  please check it.

you can create look-up object with lookupdata class from lookup.vcx

olookup = newobject("lookupdata", "lookup")

build a look-up form with a single line of code.
its very simple to build columns for a look-up window. you can do it with a simple select statement

olookup.selectcmd = [select cust_id, company, contact, title from home(2) + "\data\customer"]

but, you have to set-up a valid sql handler for sql back-ends

olookup.remote       = .t.
olookup.sqlhandler = sqlconnect("myconnection", "sa", "mypass")
olookup.selectcmd  = [select cust_id, company, contact, title from data..customer]

once you set selectcmd, it will automatically build look-up columns

ocolcompany = olookup.columns.column("company")
?ocolcompany.columndata    && prints "company"
?olookup.columns.column("cust_id").columncaption   && prints "cust id"

each column object would have following properties.
columndata    - set/return source data field for a column. column must exists in selectcmd
columncaption - set/return caption for a column. by default, non-underscore+proper case form of columndata would be columncaption.
columnname    - set/return column name
columnorder   - set/return relative order of a column
columnvisible - set/return visible state of a column
columnwidth   - set/return width of a column. if we set -1 as columnwidth, column will automatically fit to contents
sortable      - set/return whether a column is available to sort by clicking on column header.
headerimage   - set/return path of a image file to display on column header.(available only if column is not sortable)
key          - set/return a unique key for a column.

following properties/methods available for lookup class
autocenter    - manage lookup window's autocenter property
caption       - set/return lookup caption
icon          - set/return icon file for look-up window
imagesort_up  - set/return image file to display in column header, when column is sorted on ascending order.
imagesort_down - set/return image file to display in column header, when column is sorted on descending order.
selectcmd      - set/return a valid select statement to build columns
setdefaultcolumn - method to set default search column
setkeycolumn     - method to set return column
showlookup       - method to show lookup window
remote           - specify whether data is collect from a remote server
sqlhandler       - specify a valid sql handler. only available if remote is set to .t.
tmpalias         - set/return a temp alias name for underlying cursor.
casesensitive - on/off case sensitive search

please find latest file here

5 Responses to DataLookup – A framework class

  • Anil Sharma says:

    kool! nice coding. keep it up!

    # Thank you Anil… Some issues were fixed in latest attachment. Please verify it

  • akselsoft says:

    Looks great – some issues:

    a) the auto indexing doesn’t work with long field names….(try it with the TasTrade customer dbf for an example)

    b) the samples don’t work for that reason – CUST_SAMPLE looks for a wz* class library that isn’t available.

    Otherwise, great effort!


    # Hi Andrew
    Thank you for your valuable feedback
    Now I resolved this issue with creating index with a temp name.
    Please download latest attachment

    Sorry for late reply

  • bsanmarie says:

    Hello Jijo.

    How do I invoke the form from the class?

    I got as far as this:

    oLookup = Newobject(“Lookupdata”, “LookUp”)

    oLookup.SelectCmd = [Select uif_Org from r:\users\foxtest\Data\ua_Insur]

    I don’t know how to display the data like you have on this blog.

    I appreciate any guidance you can provide.



    # Hello Brad,
    First of all sorry for late reply…

    Here is how you can invoke lookup form from this class
    when you assing select command with oLookup.SelectCmd = [Select uif_Org from r:\users\foxtest\Data\ua_Insur]
    oLookup will build column object from this selectCmd.You can access each columns with their index or key.
    eg: oLookup.Columns.Column(“uif_Org”). These column object would have lot of properties to manage each columns
    in the resultant lookup form.
    When you want to bring up the lookup form, you can use ShowLookup() method.
    ie: oLookup.ShowLookup().
    One sample form is attached in Please look into it

  • bsanmarie says:

    Hello Jijo,

    Do you have a working sample to share?


    #Hello Bsanmarie,
    First of all, sorry for the late reply..
    I have already attached a working sample in
    Please run Sample_Cust form. 

  • bsanmarie says:

    Hello, Jijo.

    Is there a working sample you can share for this class? I am having a hard time understanding how this class works.



    #Hello Bsanmarie,
    First of all, sorry for the late reply..
    I have already attached a working sample in
    Please run Sample_Cust form. 

Leave a Reply

Your email address will not be published. Required fields are marked *