New call-to-action
Results 1 to 7 of 7

Thread: How do I make user select from table?

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default How do I make user select from table?

    I am interested in aircraft, part of which means that I keep a diary of all the Identites I have seen.
    the plot so far.
    1)When I goto the "Auto Logging" form, I enter the date, place name and Identities and click on the "auto Logging" button.
    2)if a match is found on the master logfile and the matched record has the "AS" field empty, the date, where & Identity
    are written to that record.
    3)if no match the same search is done on the "Logback" file. if the logback match "AS" is blank the diary details are written to this file.
    4)If multiple matches are found on the master "Logfile", the problem I have is finding a way of asking me (the user) to choose either the correct one from the list OR indicate that none of then are correct.
    5)If a match record is chosen then we go back to 2) and/or 3).
    6)if no match is correct goto 3).

    Can anyone suggest a way of doing this.
    attached is a small Zip file with the neccessary files etc.

    TIA

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,317

    Default RE: How do I make user select from table?

    I haven't looked at your zip file, but it would not be too tough to display multiple matching records using the

    ui_get_list_array() function

    The user could scroll through them and pick the one that fits...


    -- tom

  3. #3
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default RE: How do I make user select from table?

    Hi Tom,
    the problem with that command is that it only allows eight choices, which not be enough.
    Thanks for your input.

  4. #4
    "Certified" Alphaholic
    Real Name
    Ken Herrold
    Join Date
    May 2000
    Posts
    1,081

    Default RE: How do I make user select from table?

    Graham:

    I did a similar thing to select a customer name for a report. Here's what I did.......

    Created a form and imbedded a browse of the list from which to select. You could apply a query or index to this at init to get the records filtered or in the proper order.

    I have the user [using scroll bars or arrows] 'land' the highlight on the item desired. An O.K. button routine sets the [global] variable to the value of the selected line - then moves on in the script.

    This, of course can probably pick up only one value per event, but it might be something you haven't thought about.
    It works quite nicely for me resembling [somewhat] Alpha's 'picklist' utility 'out of the box'.

    Just a thought, and of course, you must realize I'm pretty new to this.

    Ken the Newbie

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,317

    Default RE: How do I make user select from table?

    There are two related functions, only one of which is limited to 8 entries:

    ui_get_list()

    and

    ui_get_list_array()


    The latter is not so limited.

    -- tom

  6. #6
    Member
    Real Name
    Stephen Williams
    Join Date
    Apr 2000
    Location
    Oakland, CA
    Posts
    930

    Default RE: How do I make user select from table?

    I DID look at your zip. Tom is right - get_list_array() is the way.

    I use it to pick assemblies in estimating and I have a list of over 40 assemblies and growing...Works beautifully.

    You might play with this code as a guide...

    ''''''''''''''''''''''''''''''''open asstc and set index to Assy

    loc = dir_get()
    tbl = Table.Open("assytc.dbf")
    indx = tbl.index_get("Assy1")
    tbl.index_primary_put(indx)
    num = indx.records_get()

    '''''''''''''''''''''''''''''''''create and fill array of Assemblies
    DIM listA (num) as C
    tbl.Fetch_First()
    FOR i = 1 TO num
    listA(i) = tbl.Assy+" "+tbl.Assitem
    tbl.Fetch_Next()
    NEXT i

    grp = ui_get_list_array("Select Assembly group",1,"listA")
    if grp = ""
    end
    end if
    Vassy = alltrim(substr(grp,1,12))
    Vassitem = alltrim(substr(grp,13,13))

  7. #7
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default RE: How do I make user select from table?

    Ok Guys,

    I went through each suggestion and finally settled on Ken's approach. I realised that I was after the recno() of the matching record so I read and re-read Chapter 22 in the XBasic Manual. After my hit-and-miss attempts I finally got it to work. What I now need to do is tidy up, I dont like having the same code spread around the same script, so if any of you can show me a tidier way to achieve the same please let me know:

    The Final Script (For those interested)

    ''XBasic
    dim logdiary as p
    dim logfile as p
    dim logback as p
    dim mindx as p
    dim bindx as p
    dim dindx as n
    dim global mrecno as n
    dim total_f as n
    dim total_b as n
    dim total_d as n
    dim global dupl as c
    dim global diary_date as d
    dim global diary_where as c
    total_f = 0
    total_b = 0
    total_d = 0
    if diary_date = {} .or. diary_where = "" then
    ui_msg_box("Date and/or Place Name Invalid","Please enter values and try again",UI_STOP_SYMBOL)
    goto done
    end if
    logdiary=table.open("logdiary")
    total_d=logdiary.records_get()
    if total_d = 0 then
    ui_msg_box("Nothing to Log!!","Please enter logging before clicking Auto Log button",UI_STOP_SYMBOL)
    goto done
    end if
    logfile=table.open("logfile")
    logback=table.open("logback")
    logfile.index_primary_put("Identity")
    logdiary.fetch_first()
    while .not. logdiary.fetch_eof()
    if logdiary.identity = "" then
    goto nextrec
    end if
    query.order="Identity"
    query.filter="Identity='"+logdiary.identity+"'"
    mindx=logfile.query_create()
    trace.writeln("MINDX="+ltrim(str(mindx.records_get()))+", IDENTITY="+trim(logdiary.identity))
    select
    case mindx.records_get() = 1
    '' Match found on logfile
    if ut(logfile.as) = "" then
    total_f = total_f + 1
    logfile.change_begin()
    logfile.as = logdiary.identity
    logfile.identity = logdiary.identity
    logfile.where = diary_where
    logfile.when = diary_date
    logfile.change_end(.t.)
    mindx.drop()
    end if
    case mindx.records_get() = 0
    '' no match found on logfile
    query.order="Identity"
    query.filter="Identity='"+logdiary.identity+"'"
    bindx=logback.query_create()
    if bindx.records_get() = 0 then
    '' No match found on logback
    total_b = total_b + 1
    logback.enter_begin()
    logback.identity = upper(logdiary.identity)
    logback.as = upper(logdiary.identity)
    logback.when = diary_date
    logback.where = upper(diary_where)
    logback.enter_end(.t.)
    bindx.drop()
    end if
    case mindx.records_get() > 1
    '' duplicate matches found on logfile
    if is_object("Logfile_Browse") then
    Logfile Browse.show()
    Logfile Browse.activate()
    else
    :Form.view("Logfile_Browse","Dialog")
    end if
    last_button = :Logfile_browse.last_pressed()
    select
    case last_button = "BUTTON1"
    mrecno = :Logfile_browse:mr.value
    :logfile_browse.close()
    logfile.index_primary_put()
    logfile.fetch_find(mrecno)
    if ut(logfile.as) = "" then
    total_f = total_f + 1
    logfile.change_begin()
    logfile.as = upper(logdiary.identity)
    logfile.identity = upper(logdiary.identity)
    logfile.where = diary_where
    logfile.when = diary_date
    logfile.change_end(.t.)
    mindx.drop()
    end if
    case last_button = "BUTTON2"
    ''No match found in Dupl List
    :logfile_browse.close()
    query.order="Identity"query.filter="Identity='"+logdiary.identity+"'"
    bindx=logback.query_create()
    if bindx.records_get() = 0 then
    '' No match found on logback
    total_b = total_b + 1
    logback.enter_begin()
    logback.identity = upper(logdiary.identity)
    logback.as = upper(logdiary.identity)
    logback.when = diary_date
    logback.where = diary_where
    logback.enter_end(.t.)
    bindx.drop()
    end if
    end select
    end select
    nextrec:
    logdiary.fetch_next()
    end while
    if total_f + total_b > 0 then
    ui_msg_box("Auto Logging",ltrim(str(total_d))+" entered into Logdiary, "+ltrim(str(total_f))+" logged in Logfile and "+ltrim(str(total_b))+" logged in logback .")
    end if
    done:
    END

Similar Threads

  1. Why is my table field not in select list.
    By Steven Taylor in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-22-2004, 09:34 PM
  2. How do I make my own application
    By jeresmall in forum Alpha Five Version 5
    Replies: 4
    Last Post: 06-04-2004, 01:44 PM
  3. User Rights Required for Table Updating
    By Red Abicht in forum Alpha Five Version 4
    Replies: 1
    Last Post: 09-11-2003, 02:42 AM
  4. Muti-Select XDialog - Select/Deselect All
    By Steve Buckler in forum Alpha Five Version 5
    Replies: 3
    Last Post: 11-27-2002, 05:13 AM
  5. Do I make a new table?
    By Elsie Beall in forum Alpha Five Version 4
    Replies: 2
    Last Post: 11-13-2001, 04:26 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
  •