Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Using a Record list -List box for selections of more than one field at a time.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Re: Using a Record list -List box for selections of more than one field at a time.

    Here's one more:

    Code:
    FUNCTION Vw_List AS C(custid as C = "")
    'DESCRIPTION: Get a list of devices for a cust_numb on the calling form
    'Ex: Vw_List() will get the current cust_numb
    DIM shared dvcSerial as C
    DIM dlgbody as c
    DIM dlgcode as c
    DIM dlgresult as C
    DIM dlgtitle as c = "XD Example"
    
    if custid = "" then
    	custid = topparent:cust_numb.value
    end if
    
    DIM dvcSerial_rl_def_orig as C 
    dvcSerial_rl_def_orig = "kl=devices,{keylist_build(\"H=.05,1:10[Serial],2:12[Testable],3:10[Make],4:8[Size],5:15[Model],6:15[Location],7:20[Cross_Con],8:15[Hazard]\",''+serial,left(''+serial,10),left(''+type,10),left(''+make,10),left(''+size,8),left(''+model,15),left(''+location,15),left(''+cross_con,20),left(''+hazard,15))}{cust_numb = [varC->custid]}"
    DIM dvcSerial_rl_def as C 
    dvcSerial_rl_def = replace_parameters(dvcSerial_rl_def_orig,local_variables())
    
    dlgbody = <<%dlg%
    {removecomments}
    {background=Blue White}
    {can_exit=!CANCEL}
    {title=Record List}
    {watch=!custid_changed}
    {xmargin=2,1}
    {region}
    {Region}
    {'%O={F=Arial,9,B}{C=Dark Blue}Enter a Cust No. then select a record from list%};
    {Endregion};
    {Region}
    Cust No: [.15custid!custid_changed];
    Select Serial No:;
    [%@dvcSerial_rl_def%.100,10dvcSerial];
    Selection: [10dvcSerial];
    {Endregion}; 
    {line=1,0};
    {lf};
    {justify=center}
    <*12OK!OK> <12Cancel!CANCEL>;
    {endregion};
    %dlg%
    
    dlgcode = <<%code%
    If a_dlg_button = "custid_changed" then 
    	dvcSerial_rl_def = replace_parameters(dvcSerial_rl_def_orig,local_variables())
    	a_dlg_button = ""
    end if
    %code%
    
    dlgresult = ui_dlg_box(dlgtitle,dlgbody,dlgcode)
    'test button user selected
    'msgbox("dlgresult",dlgresult)
    
    if dlgresult = "CANCEL" then 
    	end 
    end if
    
    dim shared dvcCrosscon as c = ""
    dim shared dvcHazard as c = ""
    dim shared dvcLocation as c = ""
    dim shared dvcMake as c = ""
    dim shared dvcModel as c = ""
    dim shared dvcTestable as c = ""
    dim shared dvcType as c = ""
    dim fltr as c = ""
    dim idx as p
    dim msg as c = ""
    dim recs as n = 0
    dim tbl as p
    
    'SERIAL is your unique record key so open the table filtered
    'and set the other 6 vars
    'that are also defined in your form
    tbl = table.open("devices",FILE_RW_SHARED)
    tbl.index_primary_put("Serial")
    recs = tbl.fetch_find(dvcSerial)
    if recs < 1 then
    	msgbox("Query Result","No records found for Serial #: "+dvcSerial,0)
    	goto CLOSETBL
    end if
    
    msg = dvcSerial+crlf()
    dvcCrosscon = tbl.cross_con
    msg = msg+dvcCrosscon+crlf()
    dvcHazard = tbl.hazard
    msg = msg+dvcHazard+crlf()
    dvcLocation = tbl.location
    msg = msg+dvcLocation+crlf()
    dvcMake = tbl.make
    msg = msg+dvcMake+crlf()
    dvcModel = tbl.model
    msg = msg+dvcModel+crlf()
    dvcTestable = tbl.testable
    msg = msg+dvcTestable+crlf()
    dvcType = tbl.type
    msg = msg+dvcType+crlf()
    
    CLOSETBL:
    tbl.close()
    'test populated vars
    msgbox("List",msg,0)
    Vw_List = dvcSerial
    END FUNCTION
    If you type
    Vw_List("00023")
    in the IW you can see what it does

    Here is the function that you can import to the Code page - save it to your desktop

    vw_List.txt
    Last edited by MoGrace; 10-29-2015, 09:34 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #17
      Re: Using a Record list -List box for selections of more than one field at a time.

      Thank you Robin, I think your code is darn close if not exactly what I am looking for. When I try to run the function from the IW as you suggested, I get a blank box without any records and an error after the box is displayed.

      From the interactive window I get the following results. First the empty �Record List� window opens and then the error code. I have attached a screen shot of the empty Record List box.

      Vw_list("00023")

      error.jpg

      ERROR: command: tbl.index_primary_put("Serial")
      Tagname not found.

      Comment


        #18
        Re: Using a Record list -List box for selections of more than one field at a time.

        Sorry about that. Just add the index to the devices table for the serial field and it should work.

        Serial was the only unique field in the table you uploaded so I used that for the key. However if you are wanting to use this on a table where serial is also repeated, then you might need to use a different table. Something like a parts table where every part has a unique ID and therefore has no duplicates.

        Keep us posted on your progress...the beauty of A5 is that there are often multiple ways to accomplish what you need.
        Last edited by MoGrace; 10-30-2015, 01:26 AM.
        Robin

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

        Comment


          #19
          Re: Using a Record list -List box for selections of more than one field at a time.

          Yes there is a million ways to do something in A5, that is for sure! I set up the index and still get a blank box the same as before, but the function does run and I have attached a jpg showing the two message boxes I receive after running the function. Also in that same JPG is a screen shot of the list box I am trying to make, it is what my original posted code created.

          The serial field is not always unique and may at times be blank or duplicated. I am also wanting that field to be copied into a variable. In my example the calling form is creating a new record for customer "0023" in a table called inspections and I want to produce a list box, like in my example, to pick which matching "0023" record from the Devices table to store into variables for later use. The list box is filtered to show only records for the cust_no("0023" in this case) we are creating a new record for.

          Without seeing the results of your list box I am not sure how close we are, but I think it is getting closer. :-)

          Thanks again, your efforts are much appreciated! error2.jpg

          Comment


            #20
            Re: Using a Record list -List box for selections of more than one field at a time.

            Hi Mike,

            I assumed that you have the two or more tables. The category(*Device) and work(*Order) tables.

            The Device table has Device_id + 8 fields
            The Order table has Order_id, Device_id and not included the same 8 fields from Device table.

            I do get (display) the 8 fields value on the Order form after selected one with List-box or dropdown.
            - create a form with a button on the form
            - The button has your code and event which save the variable(*Device_id) to Order table


            1) Using the SET method. Order(Parent, Device_id) joint Device(child, device_id)
            - simple and easy way
            - create a form with this SET table and display the 8 fields, a button on the form
            - The button has your code and event which save the variable(*Device_id) to Order table

            2) Using the calculation - one by one
            - Set the "calc->name" and get the value(*lookup() ) from category table.
            - Display the "calc->name" fields on the form.
            - The button has your code and event which save the variable(*Device_id) to Order table

            3) using the Variable - need 2nd code, get all of the 8 fields at once or one by one
            - Set the variables name
            - The button has your code and event which save the variable(*Device_id) to Order table

            - Find, read and set the value from category table
            How do I read the table? - a) table_method b) A5 List_method
            - Display the "var->name" fields on the form.
            - Refresh form on the EVENT

            Comment


              #21
              Re: Using a Record list -List box for selections of more than one field at a time.

              Hi Mike,
              Sorry you are having trouble with my function - here is a screenshot of what it does with the table you provided. Perhaps something is different in the tables since I see you have a Cust_numb of "0023" and I have "00023"?

              record_list.png
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #22
                Re: Using a Record list -List box for selections of more than one field at a time.

                Robin I retried using your function with "00023" and I still get the same results. Quite strange. The tables are the same as I posted on here with no changes. Your solution is exactly what I am looking for, except that the serial field would need to be included as well, if it worked here. I am thinking 2 things and obviously correct me if I am way off.

                First of all to get this working here, I named the "Serial" field index in the "Devices" table Serial. Is that what you named it?

                Secondly, if we can get this to work, how about if I add an auto-increment field to the devices table and we use that as the unique indexed field for this purpose? I attached a new table to reflect those changes.
                Attached Files

                Comment


                  #23
                  Re: Using a Record list -List box for selections of more than one field at a time.

                  Mike,
                  Since we are sharing files, here is the ADB I created and placed in a subdirectory of A5 named: \test\devices\ - don't know if that will make it work or not! I was able to open the list for the current customer and add several new records during testing - these show in the devices table - also using a unique DEV_ID field. I did tweak my function somewhat but only to make it more readable... Also, I am using an XP3 machine and A5v11.

                  devices.zip
                  Last edited by MoGrace; 10-30-2015, 03:24 PM.
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #24
                    Re: Using a Record list -List box for selections of more than one field at a time.

                    Ok, thanks for the files and it works fine in my test. I am going to try to create a stripped down workspace that reflects the tables and some public data I am using so you can see what I am up against. Your code is perfect, but I am trying to use it on a different form in a different table. It does not work when I do that.

                    We are getting there! Thank you for your patience and time!

                    Comment


                      #25
                      Re: Using a Record list -List box for selections of more than one field at a time.

                      Ok Robin thanks to you, I have the list box code you provided working in the form I needed it to and this is a GREAT thing. It conditionally pops up where I want it to and conditionally fills the fields I needed from the stored variables. My only remaining issue is the script does not fill in the "serial" field to a variable and I know you were using that field as the unique field earlier. I am hoping now that there is an auto-increment field in the "devices" table the addition of the serial field to the process would be a simple one.

                      Is this something easy I can change, I see where the index tag is and I suspect that should be changed to pick the auto-increment field index, adding a Dim for a new dvc_serial variable is within my abilities, I just don't know about modifying that array...

                      Comment


                        #26
                        Re: Using a Record list -List box for selections of more than one field at a time.

                        Mike,
                        Did you change the name of the var->dvcSerial to dvc_Serial? That might explain the trouble you are having.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment


                          #27
                          Re: Using a Record list -List box for selections of more than one field at a time.

                          Robin I found the problem. To get the function to work where I needed it I had changed the variables from shared to global, except the serial variable was Dim'ed near the beginning of the code and I missed it. So all is working perfectly, I may be trying to tweak the box appearance some, but basically life is good! I want to thank you and John K. and Tom C. for jumping in here and basically solving my issue for me. Since I am an Action Scripting guy, mainly, I would have never solved this riddle on my own!

                          Tip of the hat Folks !!!

                          Mike

                          Comment


                            #28
                            Re: Using a Record list -List box for selections of more than one field at a time.

                            Mike,
                            Helping resolve your scenario is also a great learning experience for me too. It's what makes this forum so great!
                            Robin

                            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                            Comment


                              #29
                              Re: Using a Record list -List box for selections of more than one field at a time.

                              Good day!

                              It has been a long time since you folks saved me on this project. I have attached the code Mograce (Robin) provided me then and it has worked perfectly until we populated the tables and a bug has appeared that I just can't seem to fix. This function opens an external table called Devices and reads a record from the table based upon the customer id number, the script then places all the fields in that chosen record on a pop-up message box and this works fine.

                              Upon picking a record from the pop-up display it writes them to variables. If the script reads a record from the Devices table with a blank or duplicate "Serial" field there is trouble. The read operation is fine, but where the stored variables are being written to a second table, the script appears to be using the "Serial" field and Serial index as the open index pointer and it stores incorrect field values.

                              I am pretty sure that if the write operation was based upon the unique record field and index in the device table called "Dev_id" it would work fine, I just can't figure out how to change it...

                              I have too much data to upload the database here and the bug won't show up without the data in it. Could I FTP it to or something a little more private if you have time to help me out??

                              Thank you in advance---- Mike




                              A_function.txt

                              Comment


                                #30
                                Re: Using a Record list -List box for selections of more than one field at a time.

                                Well after a few hours of intense monkeying around, I believe I managed to get it working. I love Alpha, and this forum!

                                Thanks once again for the fantastic help on this original thread.

                                Comment

                                Working...
                                X