Alpha Video Training
Results 1 to 3 of 3

Thread: Use variables in Xbasic for deleting duplicate records on query.order, query.filter,

  1. #1
    Member
    Real Name
    Fur-Jiang Leu
    Join Date
    Apr 2009
    Posts
    76

    Default Use variables in Xbasic for deleting duplicate records on query.order, query.filter,

    The following Xbasic code works good for deleting duplicate records. In order to use similar code for several tables, I would like to use variables. How to change all of the PaNo to var0?

    dim var0 as C = "PaNo"
    dim var1 as C = "tbl.PaNo"

    tbl = table.open("PaNo")
    query.order = "PaNo + invert(recno())"
    query.filter = "pano >= " + s_quote(min1) + ".and. pano <= " + s_quote(max1)
    query.options = "T"
    query.description = "temporary query"
    qry = tbl.query_create()
    tbl.batch_begin()
    tbl.fetch_first()
    rec_idn = tbl.paNo
    tbl.fetch_next() 'goto the next record
    while .NOT. tbl.fetch_EOF()
    if tbl.paNo = rec_idn
    tbl.change_begin()
    tbl.mark()
    tbl.change_end(.T.)
    else
    rec_idn = tbl.paNo
    end if
    tbl.fetch_next()
    end while
    tbl.batch_end()
    tbl.delete_range("marked()") 'delete all the marked records
    tbl.pack()
    tbl.close()

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Use variables in Xbasic for deleting duplicate records on query.order, query.filt

    Code:
    query.order = var0 + " invert(recno())"
    query.filter = varo+" >= " + s_quote(min1) + ".and. "+var0 +" <= " + s_quote(max1)
    
    
    if eval("tbl."+var0) = rec_idn
    ...
    ...
    else
    rec_idn = eval("tbl."+var0)
    There can be only one.

  3. #3
    Member
    Real Name
    Fur-Jiang Leu
    Join Date
    Apr 2009
    Posts
    76

    Default Re: Use variables in Xbasic for deleting duplicate records on query.order, query.filt

    Dear Stan:
    Thank you very very much. It works very good. You also helped me on the delete of (older) duplication records.
    Only one "+" need to be added for those who my need this technique.
    query.order = var0 + " + invert(recno())"
    FJ

Similar Threads

  1. duplicate records in query
    By gwsgreg in forum Alpha Five Version 9 - Desktop Applications
    Replies: 10
    Last Post: 05-13-2009, 09:04 AM
  2. Mark duplicate records based on a query
    By randygreen in forum Alpha Five Version 7
    Replies: 14
    Last Post: 12-10-2005, 07:08 PM
  3. Xbasic limit for Query.filter
    By Garry Flanigan in forum Alpha Five Version 6
    Replies: 7
    Last Post: 08-16-2005, 07:54 PM
  4. How to use Query Filter Genie in Xbasic Script?
    By Jim Chapman in forum Alpha Five Version 5
    Replies: 8
    Last Post: 02-19-2004, 08:41 PM
  5. Query or layout order & filter???
    By Tony Watts in forum Alpha Five Version 5
    Replies: 3
    Last Post: 11-08-2002, 08:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •