Alpha Video Training
Results 1 to 4 of 4

Thread: Conditional Cancel in Modal dialog script

  1. #1
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Conditional Cancel in Modal dialog script

    I have 3 forms.
    Transaction----based on trans table
    tapAdd_Trans--based on the set trans_alloc_prod (trans=>allocation_tbl,-> prod tables)...one=>many and one->one
    tSel_Vendor----based on client_info table

    From the Transaction form the Insert button is pushed which brings up both of the other forms---tapAdd_Trans form first and then tSel_Vendor second (in Modal dialog). The tSel_Vendor form is where a company is chosen for a transaction and is placed into the tapAdd_Trans form. So simply, the Transaction form is used to see a general view of transactions. The tapAdd_Trans form shows the details of each transaction. The tSel_Vendor is just a form in which to pick a company that the transaction occurred at.

    Everything works properly except for the following: When the tSel_Vendor
    form is brought up and then cancelled, I want to have the tapAdd_Trans form to close at the same time....and cancel any changes so a blank record isn't saved.
    If I close the tapAdd_Trans form from the "Cancel" button of the tSel_Vendor form I get errors due to the script running from the "Insert" button pressed on the Transaction form that first opened the tSel_Vendor form as a Modal dialog.

    I have been attempting to add a script to the Transaction form's Insert button (after the script that opens the tSel_Vendor form) that would cancel changes and close the tapAdd_Trans form if its Company field is blank. As the variable seems to retain its prior value I have set the variable value to "" when the cancel button is pushed. The simplist way I would think would be to have the script "button6.push()" which is the Cancel button of the tapAdd_Trans form. And would not mind even this work-a-round but cannot even get this to work! I cannot get the script to cancel changes or to close the form tapAdd_Trans and have tried various ways using pointers, actual paths, parentform, topparent, etc but obviously have them incorrect as any one of the methods I have attempted should work. I must be missing something very basic which would not surprise me in the least.
    I have attached a sample database for those who think they may be able to help. The easiest way for navigating is just to choose the aMENU form and it shows the way.

    Mike

    Attachment 11503

  2. #2
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default

    :-) I just realized that by setting the variable to "" on the cancel button it would also blank out the original vendor(company name) if there was one -- which of course could happen so is not the way to accomplish getting rid of the retained variable value....And now it seems that the variable does not appear to be "retained"----could simply have been a glitch on my end.
    I just tried adding the "button6.push()" which is the Cancel button of the form I wish to close to the Cancel button of the Modal form tSel_Vendor and works...but it presents the errors again, of course, because the script which follows the closing of the Modal dialog has no form open in which to operate. This is why I think that the cancel and closing of the tapAdd_Trans form must be done from the script that runs after closing the Modal form.

    Any clues or different ways to approach this would be great---just don't want to be chasing after a solution in a place that I shouldn't be .

    Mike

  3. #3
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,212

    Default my2 cents

    Mike,

    Try this, it worked for me but maybe not the completeness of stop gap you desire.

    1. Move the open tSel_vendor as dialog to an OnActivate for tapAdd_Trans. I’m not sure this makes a difference but it ‘childs’ to the form it is being coupled with more linearly…. in my obtuse mind.
    2. There are two In-line Basic scripts on the INSERT button in the Transaction form I would change. The first has the following:
    Inline Basic script1:

    if varP_Object:Company.visible = .F. then
    varP_Object:Button6.activate()
    varP_Object:Button6.push()
    I would add an Action Script to the Cancel button of the tSel_vendor window that produces a variable to defines the state of the window. I used tSVwindow=”closed”. I then changed your Inline Basic script to:
    if tSVwindow =”closed” then
    varP_Object:Button6.activate()
    varP_Object:Button6.push()
    3. The Cancel button in the tSel_Vendor form defines variable vcT_curr_company=””. I replaced the second In-Line Basic script in the INSERT Button in the Transaction form so it is:
    if vcT_curr_company=”” then
    varP_Object:Button6.activate()
    varP_Object:Button6.push()
    4. I am not sure the ‘Cancel Changes’ action in the ‘Cancel Button on the tSel_Vendor form does anything.You decide.

    That’s all I have. Good luck.

    Mike W

  4. #4
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Working

    Mike, thanks for your time. I did something different than what you had suggested but was able to do so only because of what you had done and said. I couldn't put the opening of the tSel_Vendor on the OnActivate of the tapAdd_Trans form as then it would be opened each and every time I activated it -- which would happen even if I only wanted to change or add something to the tapAdd_Trans form without wanting to change the selected vendor company. But this brought to light the possibility of why my script would not run as it was not being seen by the child form (tapAdd_Trans).
    So this is what I did:

    Everything works now as far as using the cancel button of the tSel_Vendor. On the Cancel button of the tSel_Vendor form I took off all but the cancel changes and close form scripts. On the Insert button of the Transaction form I took off everything from (and including) the script which opens the tSel_Vendor form and added in its place a button.push() script which pushes the tapAdd_Trans button that is located on the upper left side--which opens the tSel_Vendor form modally and has the "set field value" scripts. I used a if company.text = "" script there.

    The Cancel Changes script on the tSel_Vendor Cancel button is needed if I was changing a vendor company in some way or adding another one and then decided not to.

    I attached a modified sample DB with these changes for any who need to see.

    Mike

    Attachment 11513

Similar Threads

  1. Conditional Dialog Form from Browse
    By pstaver in forum Alpha Five Version 6
    Replies: 0
    Last Post: 09-22-2004, 12:50 PM
  2. Date dialog script & report script won't combi
    By rbierman@iowbar.org in forum Alpha Five Version 5
    Replies: 6
    Last Post: 12-07-2003, 08:40 AM
  3. Form opened as dialog not modal
    By Scott Emerick in forum Alpha Five Version 5
    Replies: 3
    Last Post: 08-15-2003, 07:50 AM
  4. Action Script -Cancel don't
    By Gary Phillips in forum Alpha Five Version 5
    Replies: 3
    Last Post: 02-22-2003, 05:22 AM
  5. Dialog Box OK, CANCEL
    By John Gamble in forum Alpha Five Version 5
    Replies: 11
    Last Post: 09-02-2002, 10:38 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
  •