• Creator
    Topic
  • #4298
    sfritz
    Participant

      Hello all

      I have coded a Introdlg with 3 buttons, add, find and update. When the use clicks the add button, the form launches, and writes the record sucessfully however both the form and the dialog closes, is there a way of keeping the dialog infocus, so if the user chooses to find records they aren’t launching the applet again.

      I know I am missing something probably very simple but I do appreciate the help.

      Thanks

    • Author
      Replies
    • #7758
      Support 3
      Participant

        Select the button in Formativ Form Designer, change the ModalResult value to mrNone. Alternatively, you can set the dialog ModalResult in the applet:

        ‘Close the dialog when ‘Add’ button pressed
        Sub btnAddClick(Sender)
        MainDlg.modalresult = MROK
        End Sub

        ‘Do not close the dialog when ‘Add’ button pressed
        Sub btnAddClick(Sender)
        MainDlg.modalresult = MRNONE
        End Sub

        Hope this helps.

        Advansys Support

        #7760
        sfritz
        Participant

          I have tried what you have suggested and get an error stating the following:

          Formativ Applet runtime error
          G:AdvansysFormativAppletsCDIP Monthly Activities.vbf
          Object doesn’t support this property or method: ‘iDlg.ModalResult’ at line 206, column 3

          I have attached the code for you to look at just incase I did not explain myself properly.
          Thanks in advance for your continued support.

          ‘——————————————————————————-
          ‘ Insert your comments here
          ‘——————————————————————————-
          Dim iDlg
          HRT = Chr(13) & Chr(10)
          const CAPTION = “Chronic Disease and Injury Prevention Reporting Solutions”
          logo = Utilities.GetDataDirectory & “logo.gif”

          Sub Main(Client, GWEvent)
          dim I
          dim iGuidelines, iGuideline
          dim oItem
          IntroDlg
          select case iDlg.execute
          case Btn1 AddNewRecord
          case Btn3 DisplayAllRecords(iADOObj)
          case Btn4 FindRecord(iADOObj)
          case Btn5 EditRecord(iADOObj)
          end select
          End Sub

          ‘——————————————————————————-
          Sub AddNewRecord
          CDIP_FRM.showmodal
          end sub

          Function IntroDlg
          set iDlg = Utilities.NewControlBoxDialog
          with iDlg
          .Caption = CAPTION
          .Height = 550
          .ShowWizardImage = False
          .Title = “CDIP Monthly Activities Reporting Management”
          .Button1Caption = “&Add”
          .Button3Visible = True
          .Button3Caption = “&Display All”
          .Button4Visible = True
          .Button4Caption = “&Find Record”
          .Button5Visible = TRUE
          .Button5Caption = “&Update”
          .Description = HRT & “This applet will allow you to add a new record, display ” &_
          “all records or find a record in the database.” & HRT & HRT
          end with
          set ImageCtl = iDlg.AddImageControl
          with ImageCtl
          .ImageFile = ” C:Program FilesAdvansysFormativimageslogo.gif”
          .center = TRUE
          .stretch = true
          end with
          End Function

          Sub setcalendar(Sender)
          CDIP_FRM.MonthEdit.date = now
          End Sub

          Sub Clear_form
          dim a_cnt
          CDIP_FRM.MonthEdit.date = now
          CDIP_FRM.Geographic_Area.ItemIndex = -1
          CDIP_FRM.Topic.ItemIndex = -1
          CDIP_FRM.Channel.itemindex = -1
          CDIP_FRM.Method.itemindex = -1
          CDIP_FRM.Target.itemindex = -1
          CDIP_FRM.keymessage.text = “”
          CDIP_FRM.Number_Reached.text = “”

          with CDIP_FRM.ListView.Items
          for I = 0 to .Count – 1
          if .Item(I).Selected then
          CDIP_FRM.ListView.itemindex = -1
          end if
          next
          end with
          End Sub

          Sub Add_Record
          dim iRST
          dim t_cnt
          dim iUserid
          dim iMonth
          dim iYear
          dim iArea
          dim iTopic
          dim iChannel
          dim iMethod
          dim iTarget
          dim iReached
          dim iKeymsg
          dim i_Guideline_area
          dim i_Guideline_num
          dim i_Guideline
          dim I

          call msgbox(“Adding Record”)

          iUserid = groupwise.EnvUserID
          iKeymsg = CDIP_FRM.keymessage.text
          iYear = Year(CDIP_FRM.MonthEdit.Date)
          iMonth = Month(CDIP_FRM.MonthEdit.Date)
          iChannel = CDIP_FRM.Channel.text
          iMethod = CDIP_FRM.Method.text
          iTarget = CDIP_FRM.Target.text
          iReached = CDIP_FRM.Number_Reached.text

          If CDIP_FRM.Geographic_Area.ItemIndex > -1 Then
          aidx = CDIP_FRM.Geographic_Area.ItemIndex
          iArea = CDIP_FRM.Geographic_Area.items(aidx)
          End if

          If CDIP_FRM.Topic.ItemIndex > -1 Then
          tidx = CDIP_FRM.Topic.ItemIndex
          iTopic = CDIP_FRM.Topic.items(tidx)
          End if

          with CDIP_FRM.ListView.Items
          for I = 0 to .Count – 1
          if .Item(I).Selected then
          iGuideline_area = iGuideline_area & vbnewline & .Item(I).Caption
          iGuideline_num = iGuideline_num & vbnewline &.Item(I).SubItems(0)
          iGuideline = iGuideline & vbnewline &.Item(I).SubItems(1)
          end if
          next
          end with

          Set iADOObj = CreateObject(“ADODB.Connection”)
          if isobject(iADOObj) then

          ‘ open the test data source with the Connection object
          iConnnectString = “Driver={MySQL ODBC 3.51 Driver}; Data Source=CDIP_Connect”
          iADOObj.Open iConnnectString

          ‘ Are we connected?
          if err.number = 0 then
          iSQLString = “Insert into activities_dtl (month, year, area, topic, channel, method, target, num_reached, key_message, guideline_area, guideline_num , guideline, userid) values (‘” & iMonth & “‘,'” & iYear & “‘,'” & iArea & “‘,'” & iTopic & “‘,'” & iChannel & “‘,'” & iMethod & “‘,'” & iTarget & “‘,'” & iReached & “‘,'” & iKeymsg & “‘,'” & iGuideline_area & “‘,'” & iGuideline_num & “‘,'” & iGuideline & “‘,'” & iUserid & “‘” & “)”

          ‘ ISQLString = “INSERT INTO activities_dtl(month, year, area, topic, channel, method, userid values(‘” & iMonth & “‘,'” & iYear & “‘,'” & iArea & “‘,'” & iTopic & “‘,'” & iChannel & “‘,'” & iMethod & “‘,'” & iUserid & “‘” & “)”
          ‘Msgbox iSQLString
          Set iRST = iADOObj.Execute(iSQLString)
          iADOobj.Close
          Set iRST = Nothing
          end if
          else
          call msgbox(“Failed to create ADODB.Connection object.”, vbCritical, CAPTION)
          end if
          Set iADOObj = Nothing
          End Sub

          Sub SubmitBtnClick(Sender)
          dim x, SearchString, SearchChar, MyPos

          if CDIP_FRM.Geographic_Area.ItemIndex = -1 then
          msgbox(“Please select a geographic area from the radio group”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          if CDIP_FRM.Topic.ItemIndex = -1 then
          msgbox(“Please select a topic from the radio group”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          if CDIP_FRM.Channel.ItemIndex = -1 then
          msgbox(“Please select the channel used, click on the down arrow for valid selections.”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          if CDIP_FRM.Method.ItemIndex = -1 then
          msgbox(“Please select the method used, click on the down arrow for valid selections.”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          if CDIP_FRM.Target.ItemIndex = -1 then
          msgbox(“Please select the target audience, click on the down arrow for valid selections.”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          SearchString = CDIP_FRM.Method.Text ‘ String to search in.
          SearchChar = “Media Campaign” ‘ Search for “P”.
          MyPos = Instr(1, SearchString, SearchChar, 1)

          if (MyPos > 0 and CDIP_FRM.keymessage.Text = “”) then
          msgbox (“You must enter the key message when using a Media Campaign method”)
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          end if

          if (CDIP_FRM.ListView.itemindex < 0) then
          msgbox(“Select the applicable guideline from the list to proceed.”)
          CDIP_FRM.ListView.setfocus
          CDIP_FRM.SubmitBtn.ModalResult = MRNONE
          exit sub
          end if

          Add_Record
          myvar = Msgbox (“Do you wish to add another record?”,vbYesNo )
          if myvar = vbYes then
          Clear_form
          end if
          if myvar = vbNo then
          CDIP_FRM.ModalResult = MROK
          end if
          iDlg.ModalResult = MRNONE
          End Sub

          Sub CancelClick(Sender)
          exitvar = Msgbox (“Exit without saving changes?”,vbYesNo )
          if exitvar = vbYes then
          CDIP_FRM.CANCEL.ModalResult = MRCANCEL
          end if

          if exitvar = vbNo then
          CDIP_FRM.ModalResult = MRNONE
          end if
          End Sub

          #7759
          Support 3
          Participant

            Which version of Formativ framework are you running (See Help – About Formativ)?

            Formativ 1.6 only shows modal dialog which has to be closed to continue other process including showing another dialog. In your case, you need to re-display the main dialog once the secondary dialog closed.

            Formativ 2.0 allow you to build custom forms and dialogs using the dynamic visual forms designer and you can display secondary dialog while the main dialog is visible. The earlier response was based on Formativ 2 framework. See the web link below for more information about creating solution with Formativ 2:
            http://www.advansyscorp.com/formativ_development_more.htm

            If you are using Formativ Framework 2.0 then we highly recommend you to use the Formativ 2 Forms. See the ‘Formativ Users Guide’ for more information about creating, displaying Forms. Please do not hesitate to contact us if you have any further questions or comments.

            Regards,
            Advansys Support

          Viewing 3 replies - 1 through 3 (of 3 total)
          • You must be logged in to reply to this topic.