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

Change and Add New record to same table

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

    Change and Add New record to same table

    Hi there,

    I'm trying to change a record, and then add New record to the same table.

    I did it using the Xdialog, and the data are reflected in the sub-form.

    However, I would need to press F9 to save the content to the table.

    Did I do anything wrong with the script below...???

    Or did I used the Change_Begin ... Change_End & Enter_Begin ... Enter_End incorrectly??? any suggestions...






    PHP Code:
    'Date Created: 21-Feb-2008 20:29:00 PM
    '
    Last Updated22-Feb-2008 12:59:13 AM
    'Created By  :
    '
    Updated By  
    'Create an XDialog dialog box to prompt for parameters.
    '
    In order to evaluate expressions using the eval() function, in the context of 
    'the current form, the "form_name" variable is defined.
    DIM form_name as C
    if is_object(topparent.this) then 
        form_name = topparent.name()+".this"
    else
        form_name = ""
    end if

    dim t1 as P
    t1 = table.get("EStkloc")
    t1.fetch_first()
    '
    Stkloc Values ...
        
    DIM SHARED Vlocno AS c
        VLocno 
    topparent:Browse4:Stklocno.value
        trace
    .WriteLn("Vlocno = "+Vlocno )
        
    DIM SHARED Vstkinno AS c
        Vstkinno 
    topparent:Browse4:Stkinno.value
        trace
    .WriteLn("Vstkinno = "+Vstkinno)
        
    DIM SHARED Vsupno AS c
        Vsupno 
    topparent:Browse4:Supno.value
        Trace
    .WriteLn("Vsupno = "+Vsupno)
        
    DIM SHARED Vprodno AS c
        Vprodno 
    topparent:Browse4:Prodno.value
        DIM SHARED VStklocdate 
    AS d
        VStkLocdate 
    topparent:Browse4:Stklocdate.value
        DIM SHARED VStklocatn 
    AS c
        VStkLocatn 
    topparent:Browse4:Stkloclocations.value
        DIM SHARED VLocind 
    AS n
        VLocind 
    topparent:Browse4:Stklocind2.value


    dim shared recnum 
    as N
    dim thiskey 
    as C
    DIM SHARED VLocDate 
    as D
    DIM SHARED VLoc 
    as C
    DIM SHARED VTag 
    as C
    DIM SHARED varC_result 
    as C
    DELETE expression_result
    expression_result 
    = eval("date()",form_name)
    VLocDate convert_type(expression_result,"D")
    VLoc ""
    heading_string "Select TAG"
    footer_string "3333"
    ok_button_label "&OK"
    cancel_button_label "&Cancel"
    DIM VLoc_rl_def as 
    VLoc_rl_def 
    "k=rackloc,{keylist_build(\"H=.025,1:21[STORE]\",''+Raklocnam,left(''+Raklocnam,21))}{.t. .and. unique_key_value()}"
    DIM VTag_rl_def_orig as 
    VTag_rl_def_orig 
    "k=rackloc,{keylist_build(\"H=.025,1:21[Rack Tag]\",''+Rakloctag,left(''+Rakloctag,21))}{Raklocnam = [varC->VLoc]}"
    DIM VTag_rl_def as 
    VTag_rl_def 
    replace_parameters(VTag_rl_def_orig,local_variables())
    varC_result ui_dlg_box("Locations",<<%dlg%
    {
    region}
    {
    text=36,1:heading_string};
    {
    endregion};
    {
    region}
    Stkloc No:| {text=Vlocno};
    Stkin No:| {text=Vstkinno};
    Sup No|    {text=Vsupno};
    Prod No| {text=Vprodno};
    Loc Date| {text=Vstklocdate};
    Locations| {text=Vstklocatn};
    {
    lf};
    {
    endregion};
    {
    region}

    Select STORE:| [%@VLoc_rl_def%.21VLoc!VLoc_changed];
    Select TAG:| [%@VTag_rl_def%.21VTag];
    {
    endregion};
    {
    region}
    {
    text=36,1:footer_string};
    {
    endregion};
    {
    line=1,0};
    {
    region}
    <
    15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {
    endregion};
    %
    dlg%,<<%code%
    '
    ''
    '''
    '   BELOW three sets of IF...END IF, which are used to "CHANGE" focus for the input 
    '    
    Dialog box selection criteria...
    '''
    ''
    '
    if left(a_dlg_button,9) = "VLocDate" then 
        
    if a_dlg_button "VLocDate_killfocus" then 
            VLocDate 
    ctod(dtoc(VLocDate))
        
    end if 
        
    a_dlg_button ""
    end if 

    If 
    a_dlg_button "VLocDate_changed" then 
        VTag_rl_def 
    replace_parameters(VTag_rl_def_orig,local_variables())
        
    a_dlg_button ""
    end if 


    If 
    a_dlg_button "VLoc_changed" then 
        VTag_rl_def 
    replace_parameters(VTag_rl_def_orig,local_variables())
        
    a_dlg_button ""
    end if

    '
    ''
    '''
    '   On "OK" pressed, the following statements will be executed. Otherwise, the Dialog
    '    
    box will keep displaying.
    '''
    ''
    '
    If a_dlg_button "OK" then

    dim indx_1 
    as P

    indx_1 
    t1.index_primary_put("Reloc")
        
        
        
    'Browse2/Stkin Values ...
        DIM SHARED VB2NO AS c
        VB2NO = topparent:Browse2:Stkinno.value
        DIM SHARED VB2BAL AS n
        VB2BAL = Topparent:Browse2:Withdraw.value
        DIM SHARED VB2QTY AS n
        VB2QTY = topparent:Browse2:Qty_in.value
        

        thiskey = Alltrim(VB2NO)+","+VLocind
        trace.WriteLn("tis key = "+thiskey)
        recnum = t1.fetch_find(thiskey)
        Trace.WriteLn("LocInput3 RECNUM = "+recnum)
        Trace.WriteLn("END>>>")
    IF recnum > 0 then
       '
    record exits
       ui_msg_box
    ("Record Exists","Only one record may be assigned here.",UI_INFORMATION_SYMBOL+UI_OK)
    IF (
    VB2Qty VB2Bal) <= 0 then
        ui_msg_box
    ("EMPTY RECORD","Stock empty or Dummy record... Please select a Valid Record.",UI_INFORMATION_SYMBOL+UI_OK)
        
    END
    end 
    if

    trace.WriteLn("STARTS ... ")
    t1.fetch_first()
    t1.change_begin(.t.)
    '    t1.stkloclocations = VTag
        t1.stkchgdate = date()
        t1.stklocind2 = 2
    t1.change_end(.t.)
    Trace.WriteLn("Change = "+t1.stkchgdate)
    '
    t1.fetch_eof()
    sleep(2)
    t1.enter_begin(.t.)
    Trace.WriteLn("NEW REC")
        
    t1.stkinno Vstkinno
        t1
    .supno Vsupno
        t1
    .Prodno Vprodno
        t1
    .Stklocdate date()
        
    t1.Stkloclocations VTag
        t1
    .stklocind 2
        t1
    .stklocind2 1
    DIM SHARED VTem2 
    AS c
    VTem2 
    topparent:Browse2:Stkinno.value
        trace
    .WriteLn("Stkinno 1 = "+VTem1)
    t1.enter_end(.T.)

    t1.close()

       
    end
       
    else
       
    ' Record Does Not Exist. Entry is ok

    If VB2No = "" then
       ui_msg_box("NO RECORD FOUND","Invalid Assignment... Please select a Valid record.",UI_INFORMATION_SYMBOL+UI_OK)
       END
    end if

    IF (VB2Qty - VB2Bal) <= 0 then
        ui_msg_box("EMPTY RECORD","Stock empty or Dummy record... Please select a Valid Record.",UI_INFORMATION_SYMBOL+UI_OK)
        END
    end if
        ui_msg_box("REcord does not exist","You may be allow to allocate",UI_INFORMATION_SYMBOL+UI_OK)
    '    
    end

    end 
    if
    end if

    If 
    a_dlg_button "CANCEL" then
       END
    end 
    if

    END
    %code%) 

    #2
    Re: Change and Add New record to same table

    Chris,

    I don't see anything inherently wrong in your script...are you sure it is not just a refresh / repaint issue. Check your table after running the script (and before pushing F9) to see if the new record has been added.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________



    Comment


      #3
      Re: Change and Add New record to same table

      Hi Mike,

      I have compact both the tables and the DB. The error still persist.

      The record will appear on the form, but if I press ESC, the data will be removed...

      I gone thru the scripts and field rules, and find no clues what is wrong, hence hope you guys can help....


      Chris

      Comment


        #4
        Re: Change and Add New record to same table

        Sample data would help us help you. Seeing the script run in context is often key.

        Comment


          #5
          Re: Change and Add New record to same table

          Hi Tom,

          I'll prepare one and post it up...

          Comment


            #6
            Re: Change and Add New record to same table

            Respond to Mike,

            I've just done a simple test.

            When I press ESC, after the record is entered, a message box appears and asked if I would like to save the record...

            When I press "NO" the record is not saved...

            Chris

            Comment


              #7
              Re: Change and Add New record to same table

              Start the database using the "Main Input 5".

              Then flip to Page 2.

              Select any record from "Stock In" browse, other than the first rec.
              (you should be able to see the location from "STock Location" form.)

              To change the location, Press the "Loc Chg" button on the top right panel.

              Then select the store Name, and then the Rack Tag and press OK, to complete the entry.

              Observed the F9 button on the panel....


              Chris
              Last edited by ChrisTeo; 02-22-2008, 05:00 PM. Reason: Clean up the surface of the input panel

              Comment


                #8
                Re: Change and Add New record to same table

                Chris,

                The OK button on the xdialog is disabled so could not proceed--a bit of corruption noticed in the zip file may have contributed maybe. Does this replacement zip file correct this??

                I also noticed you are using a set based form but no reference made to a set in your script---that and the point that the set and a form have the exact same name may be confusing Alpha....just a couple of thoughts (may not even have anything to do with your current problem).

                Usually have to at least get or open the parent of a set before get or opening a child--then Alpha knows where to start.
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: Change and Add New record to same table

                  Mike,
                  The gray out of the OK key is line 81 of locChg script.
                  Code:
                  .and. isdate(dtoc(VLocDate,"7/")
                  I removed this and at least the OK button showed. But I get a bunch of warning dialogs that I don't know what they are supposed to mean, and then an error variable vTem1 not found for line 168.
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Change and Add New record to same table

                    Thanks Mike,

                    Maybe Chris trimmed a bit too much off the DB in the sample. I will wait til Chris responds to my prior question before pursuing further as the first zip had some corruption and even if the second doesn't, if more is to be added I don't want to keep downloading them! :)
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #11
                      Re: Change and Add New record to same table

                      Hi there,

                      I believe I got the problem fixed.

                      The code I attached earlier on (shown below) - once the three lines, in red, are removed. The code works well...

                      Thanks for all the advises and suggestions.....

                      Cheers
                      Chris:o

                      P/S: Would be good if anyone can explain why this has happened...??? thanks

                      t1.fetch_first()
                      t1.change_begin(.t.)
                      ' t1.stkloclocations = VTag
                      t1.stkchgdate = date()
                      t1.stklocind2 = 2
                      t1.change_end(.t.)
                      Trace.WriteLn("Change = "+t1.stkchgdate)
                      't1.fetch_eof()
                      sleep(2)
                      t1.enter_begin(.t.)
                      Trace.WriteLn("NEW REC")
                      t1.stkinno = Vstkinno
                      t1.supno = Vsupno
                      t1.Prodno = Vprodno
                      t1.Stklocdate = date()
                      t1.Stkloclocations = VTag
                      t1.stklocind = 2
                      t1.stklocind2 = 1
                      DIM SHARED VTem2 AS c
                      VTem2 = topparent:Browse2:Stkinno.value
                      trace.WriteLn("Stkinno 1 = "+VTem1)

                      t1.enter_end(.T.)

                      Comment


                        #12
                        Re: Change and Add New record to same table

                        Chrisl

                        Very possible that this mixing of table and form methods is confusing Alpha---try those lines outside (after) your working script ends and it should work...may have to activate the form first (may even do it prior to the script).

                        ...others may know for sure.
                        Mike
                        __________________________________________
                        It is only when we forget all our learning that we begin to know.
                        It's not what you look at that matters, it's what you see.
                        Henry David Thoreau
                        __________________________________________



                        Comment


                          #13
                          Re: Change and Add New record to same table

                          Mike

                          Will definitely try out your ideas and chk the outcome...

                          For me there are still plenty to learn before I move on to A5V8 or the platinium version...

                          Cheers:)
                          Chris

                          P/S: BTW Is there really a Platinium version coming soon?

                          Comment

                          Working...
                          X