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

Getting fields in a record into a drop down list.

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

    Getting fields in a record into a drop down list.

    Ok, trying to figure out the best way to tackle this.

    I have a child table in a set that stores user entered sizes.

    Matrix_Id,16,0
    Matrix,C,20,0
    Dsize0,C,12,0
    Dsize1,C,12,0
    Dsize2,C,12,0
    Dsize3,C,12,0
    Dsize4,C,12,0
    Dsize5,C,12,0
    Dsize6,C,12,0
    Dsize7,C,12,0
    Dsize8,C,12,0
    Dsize9,C,12,0
    Dsize10,C,12,0
    Dsize11,C,12,0
    Dsize12,C,12,0
    Dsize13,C,12,0
    Dsize14,C,12,0

    What I need to do is get the values of Dsize0 through Dsize14 plus the Matrix_ID to link it into another table that would have 15 records in it associated with the Matrix_ID that could then be used for a table drop down list to select from when entering data into fields in another table.

    The selection table would have these fields.
    Matrix_Id,16,0
    Dsize,C,12,0

    This selection table would need the records in it rewritten anytime the user selected a different Matrix to use.

    I think I have an idea on how to do it so I am just bouncing the question around here to basically see if I will be going about this right.

    On the invoice form there is a filed where the select which pricing matrix they use.

    My thoughts are to use the On Change event to fire a script that would zap the table that would be used for drop down selection in other places on the invoice and then using a loop to write the data from the child table in the Matrix set to the selection table.

    #2
    Re: Getting fields in a record into a drop down list.

    Hi Preston,
    If you populate the other table with multiple lookups for each of these fields, it is going to be incredibly slow.

    An Xdialog might be a better way to go. You could have a variable that selects the MatrixID and then based on that value populate a list filtered with the Dsizes you want to see. Set a shared variable with the value the user selects and populate your table field when the user selects OK.

    Since your Dsize fields are numbered, you could populate a list first with an array that fetches thru the table filtered by the MatrixID. How about a small sample of your data - 5 or 6 Matrix records should be enough to set up an example.
    Robin

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

    Comment


      #3
      Re: Getting fields in a record into a drop down list.

      Why not do a field rule table lookup tied to (filtered on) the current matrix id?

      Or a form list box.

      mszmast.zipmsizes.zip
      Last edited by Stan Mathews; 06-01-2015, 04:32 PM.
      There can be only one.

      Comment


        #4
        Re: Getting fields in a record into a drop down list.

        Stan,
        How would he select from the 15 fields? He'd still need 15 different lookups - one for each Dsize
        Robin

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

        Comment


          #5
          Re: Getting fields in a record into a drop down list.

          Amended my original suggestion.

          The problem is the denormalized size table. should be one record per matrix_id and size.
          There can be only one.

          Comment


            #6
            Re: Getting fields in a record into a drop down list.

            I think he wants to create something like this from the matrix table records:

            dsize_lu.jpg

            Edit: Looks like you beat me to it!

            Now all we need is the structure of the "other table" he wants the lookup FRUL for.
            Last edited by MoGrace; 06-01-2015, 04:45 PM.
            Robin

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

            Comment


              #7
              Re: Getting fields in a record into a drop down list.

              Ok, in the ExampleMat file there is the full matrix set and tables. There is also an example wo set.

              In the Matrix on the DTG or Transfers tab, Dsize1A and Dsize1B get alltrim'ed and then combined into Dsize1. So Dsize1A with a value of 5 and Dsize1B with a value of 5 would result in Dsize1 having a char value of " 5 x 5 "

              Dsize0 is always going to have the value of "" so that the first option in the drop down would be blank.
              Last edited by preston2; 06-02-2015, 10:21 AM. Reason: Removed example download

              Comment


                #8
                Re: Getting fields in a record into a drop down list.

                Got it. May not be the cleanest way to get it done but it works.

                Code:
                dim vc_dsize as c
                dim vc_dsize0 as c
                dim vc_dsize1 as c
                dim vc_dsize2 as c
                dim vc_dsize3 as c
                dim vc_dsize4 as c
                dim vc_dsize5 as c
                dim vc_dsize6 as c
                dim vc_dsize7 as c
                dim vc_dsize8 as c
                dim vc_dsize9 as c
                dim vc_dsize10 as c
                dim vc_dsize11 as c
                dim vc_dsize12 as c
                dim vc_dsize13 as c
                dim vc_dsize14 as c
                dim vn_matrix_id as n
                
                
                vc_dsize0 = ""
                vc_dsize1 = dtg_size->dsize1
                vc_dsize2 = dtg_size->dsize2
                vc_dsize3 = dtg_size->dsize3
                vc_dsize4 = dtg_size->dsize4
                vc_dsize5 = dtg_size->dsize5
                vc_dsize6 = dtg_size->dsize6
                vc_dsize7 = dtg_size->dsize7
                vc_dsize8 = dtg_size->dsize8
                vc_dsize9 = dtg_size->dsize9
                vc_dsize10 = dtg_size->dsize10
                vc_dsize11 = dtg_size->dsize11
                vc_dsize12 = dtg_size->dsize12
                vc_dsize13 = dtg_size->dsize13
                vc_dsize14 = dtg_size->dsize14
                vn_matrix_id = matrix->matrix_id
                
                a_tbl = table.open("dsize")
                ON ERROR GOTO ERROR01062015202825152
                
                
                a_tbl.delete_range(".T.")
                
                
                GOTO CONTINUE01062015202825152
                ERROR01062015202825152:
                ON ERROR GOTO 0
                ui_msg_box("Error","Error running Mark/Un-mark/Delete Operation"+crlf()+error_text_get())
                END
                CONTINUE01062015202825152:
                a_tbl.close()'If the Operation is run from within a Form or Browse, then refresh the window
                if is_object(topparent.this) then
                	if topparent.Class() = "form" .or. topparent.class() = "browse" then
                		topparent.Refresh_layout()
                	end if
                end if
                
                'Open the table that you want to write records to...
                dim tbl as p 
                tbl = table.open("dsize",FILE_RW_SHARED)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize0,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize1,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize2,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize3,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize4,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize5,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize6,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize7,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize8,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize9,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize10,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize11,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize12,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize13,"Character")
                tbl.enter_end(.t.)
                
                tbl.enter_begin()
                tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                tbl.DSIZE = convert_type(vc_dsize14,"Character")
                tbl.enter_end(.t.)
                
                tbl.close()

                Comment


                  #9
                  Re: Getting fields in a record into a drop down list.

                  Hi Preston,
                  In your dtg_size table the dsize## fields are filled with calculations based on 2 other field values. If those calculated values never change once created then your dsize table will be static. However if you create the dsize lookup table with the A and B fields, you can make the dsize calc field dynamic for your lookup table. Then your script can update the A and B values from whatever source they come from.

                  DSIZE.DBF

                  matrixid
                  ds_name
                  ds_a
                  ds_b
                  ds_val calc frul = IF(DS_A="","",ALLTRIM(DS_A) +" X "+ALLTRIM(DS_B))

                  When defining the lookup, you filter on matching Matrixid and display the ds_name and ds_val fields.

                  dsize_lookup.jpg
                  Last edited by MoGrace; 06-02-2015, 11:10 AM.
                  Robin

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

                  Comment


                    #10
                    Re: Getting fields in a record into a drop down list.

                    Robin,

                    The Dsize# fields can change and are not static. The end user can change the resulting Dsize# at any time by change the values in the Dzise#A and Dsize#B fields.

                    The script I posted above clears the Dsize.dbf table out and then recreates it based on the current Dsize# field values in the Dtg_size.dbf table that is a child of the Matrix table.

                    I could probaly get away without even putting the Matrix_ID field in the Dsize table as linking to the correct record in the Dtg_Size table is done in the set structure.

                    The result is that the Dsize table only has the values from one Matix_Id record at a time.

                    Someone with a real slow computer may notice a 1/2 second delay or so as the Dsize table is cleared and rewritten but on my computer it happens instantly.

                    Comment


                      #11
                      Re: Getting fields in a record into a drop down list.

                      Preston,
                      My thoughts were following on Stan's post #5. But not knowing how, when or why this data is changed in the dtg_size table, left me with guessing. I am sure your table structures are necessary for this matrix style app - which is much too complicated for me!

                      However your script that populates the dsize table, still suggests that an array might be useful - I will bow to Stan on that one...
                      Robin

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

                      Comment


                        #12
                        Re: Getting fields in a record into a drop down list.

                        You could shorten your script a bit.

                        Code:
                        dim vc_dsize as c
                        dim vn_matrix_id as n
                        for qx = 0 to 14
                        	evaluate_template("dim vc_dsize"+alltrim(str(qx)) +" as c")
                        	eval("vc_dsize"+alltrim(str(qx))) = eval("dtg_size->dsize"+alltrim(str(qx)))
                        next qx
                        vc_dsize0 = ""
                        vn_matrix_id = matrix->matrix_id
                        
                        a_tbl = table.open("dsize")
                        ON ERROR GOTO ERROR01062015202825152
                        a_tbl.delete_range(".T.")
                        
                        
                        GOTO CONTINUE01062015202825152
                        ERROR01062015202825152:
                        ON ERROR GOTO 0
                        ui_msg_box("Error","Error running Mark/Un-mark/Delete Operation"+crlf()+error_text_get())
                        END
                        CONTINUE01062015202825152:
                        a_tbl.close()'If the Operation is run from within a Form or Browse, then refresh the window
                        if is_object(topparent.this) then
                        	if topparent.Class() = "form" .or. topparent.class() = "browse" then
                        		topparent.Refresh_layout()
                        	end if
                        end if
                        
                        'Open the table that you want to write records to...
                        dim tbl as p 
                        tbl = table.open("dsize",FILE_RW_SHARED)
                        
                        for qz = 0 to 14
                        tbl.enter_begin()
                        tbl.MATRIX_ID = convert_type(vn_matrix_id,"Numeric")
                        tbl.DSIZE = convert_type(eval("vc_dsize"+alltrim(str(qz))),"Character")
                        tbl.enter_end(.t.)
                        next
                        
                        tbl.close()
                        Last edited by Stan Mathews; 06-02-2015, 04:18 PM.
                        There can be only one.

                        Comment


                          #13
                          Re: Getting fields in a record into a drop down list.

                          Stan,

                          I am no where near as good as you are with xbasic.

                          Mine works but is long winded. When I first looked at the streamlined version you posted I said to myself "WTF" but after looking at it I think I see how it works.

                          Will give it a try.

                          And Thanks.

                          Comment


                            #14
                            Re: Getting fields in a record into a drop down list.

                            I don't know if I'm particularly good at it or not. I just beat at the keyboard until it does what I want. Persistence != proficiency.

                            My code is the same as yours but I took the repetitive parts and wrapped them in loops so that the code writes itself. Neither bettor nor worse, just more compact. The one advantage I've found to doing it this way is that if you decide you need more or fewer sizes, you just adjust the loop counter, not add or delete code lines.

                            If you really want to get tricky, have your code count the size fields in dtg_size and use that count in the code. That way you just edit the table structure and the code adjusts itself.


                            Code:
                            tbl = table.open("dtg_size")
                            all_flds = tbl.field_name_get()
                            ? all_flds
                            = matrix_id
                            dsize0
                            dsize1
                            dsize2
                            
                            size_flds = ""
                            for each foo in all_flds
                            #size_flds = size_flds+if(left(foo.value,5) = "dsize",foo.value+crlf(),"")
                            #next
                            ? size_flds [COLOR="#0000FF"]'from my abbreviated table of the same name[/COLOR]
                            = dsize0
                            dsize1
                            dsize2
                            
                            ? line_count(size_flds)
                            = 3
                            
                            tbl.close()
                            Last edited by Stan Mathews; 06-02-2015, 05:29 PM.
                            There can be only one.

                            Comment


                              #15
                              Re: Getting fields in a record into a drop down list.

                              Stan,

                              I beat on the keyboard until I get something working too.

                              I am just not as versed in some of the code tricks and short cuts.

                              I had originally tried a loop but could not get the right code inside the loop to actually write the table records right.

                              But I have found that when I get stuck, if I come here and post I seem to figure things. Sometimes with the gracious help of others here and sometimes just having the light bulb turn on.


                              And as always. Thanks to all.

                              Comment

                              Working...
                              X