Alpha Video Training
Results 1 to 11 of 11

Thread: Field Selection by Expression or Variable

  1. #1
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default Field Selection by Expression or Variable

    I need to write a variable in one of seven different fields, depending on the value of another variable or expression.

    I could write a chain of If... Elseif.. conditionals but this would be very clumsy.

    Is there a better way of doing it?

    Thanks

    Robin

  2. #2
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,636

    Default

    I wonder if the Select / End Select function would be a good solution for you.
    -Steve


  3. #3
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    Thanks Steve, but Select... Case etc. is really only a variation on If... Else if...

    I would still have to have the action to be taken mentioned seven times.

    What would be very useful to me is to be able to specify the control in which the data is to be inserted as part of an array, eg. Box[n] where n is from 1 to 7

    But I don't think we can do that... sigh...

    Cheers

    Robin

  4. #4
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,636

    Default

    Well, maybe someone else understands what you want to do -- I guess I don't. If no one else answers and you'd like to 'splain some more then maybe other solutions can be suggested. Even if it's not in "perfect" Xbasic or whatever, perhaps write out the logic-stream that you want to create.
    -Steve


  5. #5
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    Sorry Steve if I am not clear!

    I have seven small textboxes on a form I call "Historic Person". These correspond to the British census years 1841 - 1901

    I have another form called "Individual" which has a unique index number, plus the census year, and a textbox in which the I want the user to be able to optionally insert the index number of a selected "Historic Person" form.

    On doing this the "Individual" index number is to be written in the small textbox on the "Historic Person" form which corresponds to the correct census year.

    This will result in a person looking at the "Historic Person" form being able to see which individual census records may correspond with the H.P.

    Clear as mud?? Genealogy can be a bit confusing.

    I have put pictures up on my website

    http://robin.net.nz/census

    which may make things more understandable!

    Thanks for your interest

    Robin

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

    Default

    Robin,

    Why do you have separate fields for each census? When I see repeating patterns I wonder if the table structure is correct. If you had a single "census year" field, you could define a simple list field rule lookup for it, so that the user could only enter 2001, 1991, 1981, etc. Then, regardless of what census year pertains to an "individual" only a single field in the "historic person" form would have to be updated.

    Your present design makes this complicated if you later want to find an "individual" in the "historic persons" table. You now have to search all 7 census fields in all records, since you may not know which census year pertains to the "individual" you are searching for. Much much easier to only have to search one field.

    -- tom
    Last edited by Tom Cone Jr; 01-06-2006 at 02:41 PM.

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

    Default Simplistic example

    Quote Originally Posted by Robin Hoare
    Sorry Steve if I am not clear!

    I have seven small textboxes on a form I call "Historic Person". These correspond to the British census years 1841 - 1901

    I have another form called "Individual" which has a unique index number, plus the census year, and a textbox in which the I want the user to be able to optionally insert the index number of a selected "Historic Person" form.

    On doing this the "Individual" index number is to be written in the small textbox on the "Historic Person" form which corresponds to the correct census year.

    This will result in a person looking at the "Historic Person" form being able to see which individual census records may correspond with the H.P.

    Clear as mud?? Genealogy can be a bit confusing.

    I have put pictures up on my website

    http://robin.net.nz/census

    which may make things more understandable!

    Thanks for your interest

    Robin
    Not sure I understand it all but the attachment uses two variables (acval and which) and writes the contents of "var->acval" to a field (cfld1 thru cfld7) depending on the contents of "var->which".

    Maybe it will get you started.

    No error checking is included to validate that the field actually exists - IOW it will attempt to write to cfld212 if 212 is entered in var->which, and fail.
    Last edited by Stan Mathews; 03-28-2006 at 03:24 PM.

  8. #8
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    Tom:

    Because (one hopes) all or some of the seven spaces will be filled with "Individual" numbers so that one may trace the Historic Person's census records through the years. Often there is doubt about whether one has the right records, especially with a name like John Brown (and I have one of him!)

    Thanks

    Robin

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

    Default

    Robin,

    Ok. The classic database approach to this would be to create a child table and link it one to many to the parent. Each Historic Person record would be linked to one or more child table records each of which would hold the HP id, the Individual Id, and a census year. You'll have to add a field to the structure of your HP table when the 2011 census becomes available. Right? You have to set aside storage in each HP record for 7 census fields even if some will never be used. Right?

    If you used a separate table you'd just write a new record to capture the Individual ID and link it to an HP.

    If you keep your present structure you're going to have to write the kind of Select / End Select sequence (or If, Elseif, Elseif...) as you initially supposed.

    -- tom

  10. #10
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    Thanks, Stan: I will work along those lines. The sample database was very helpful. So much compressed in so few instructions!

    Tom: thanks for that. When the 1911 census becomes available I will be able to sell an updated version, I hope! Then there should be available Alpha 5 version 12, I expect, easier than ever to use!

    Robin

  11. #11
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    Just to report success! Thanks to all who answered me. I had to struggle with XBasic for the first time and adapted Stan's suggestion: I'm sure it's all very good for me. Who needs to play bridge or chess for mental exercise?

    Kia ora

    Robin

Similar Threads

  1. A/S set Variable to Constant or Expression
    By John Gamble in forum Alpha Five Version 6
    Replies: 11
    Last Post: 12-14-2005, 06:34 PM
  2. Set session variable from grid selection
    By Pat Bremkamp in forum Web Application Server v6
    Replies: 2
    Last Post: 09-27-2004, 08:57 PM
  3. Question about Set Variable to Expression Result
    By Robert Cheley in forum Alpha Five Version 5
    Replies: 1
    Last Post: 07-08-2003, 07:52 PM
  4. variable in a report order expression
    By Mary Nickerson in forum Alpha Five Version 4
    Replies: 3
    Last Post: 01-17-2003, 04:18 AM
  5. Using Script Variable in Expression
    By Dean Hall in forum Alpha Four Versions 7 and 8
    Replies: 4
    Last Post: 11-01-2002, 04:42 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
  •