1 Reply Latest reply: Apr 7, 2014 5:07 PM by Fernando Keuroglian RSS

    VBScript module with if else

    geo gou

      Hello.

       

      I have the below VBscript module that with a button inserts the values that the variables of input boxes are given by the user into an oracle table.

       

      sub insert_oracle

       

      set myStoreval = ActiveDocument.Variables("STOREVAL")

      insStore = myStoreval.GetContent.String

      set myItemval = ActiveDocument.Variables("ITEMVAL")

      insItem = myItemval.GetContent.String

      set myPriceval = ActiveDocument.Variables("PRICEVAL")

      insPrice = myPriceval.GetContent.String

       

      set dbinsval = CreateObject("ADODB.Connection")

      dbinsval.open "DSN=xxx;UID=xxx;PWD=xxx"

      set insertvalfile = dbinsval.execute("INSERT INTO QLIKVIEW (STORE, ITEMKEY, PRICEKEY) VALUES (' " & insStore & " ', ' " & insItem & " ', ' " & insPrice & " ') ;")

      set insertvalfile = dbinsval.execute("COMMIT;")

      dbinsval.Close

       

      myStoreval.SetContent " ",true

      myItemval.SetContent " ",true

      myPriceval.SetContent " ",true

       

      end sub

       

      How can i tell if the variables are empty send a message "You must fill all the input boxes" else if the user has fill all the input boxes send another message with option "You have to insert Values into the table Are you sure ?  Yes or No."

      With No to exit from the Sub and with Yes to execute the insert.

       

      Can anyone help me to create this code ?

       

      Thank you in advance.

        • Re: VBScript module with if else
          Fernando Keuroglian

          Hi, i give you and example:

           

          reloadPrompt=MsgBox("Confirm report",4,"Confirm Generation")

          if reloadPrompt = vbYes then

          call LoadingVisible

          else

          end sub

           

          another thing to do to controle the text that the user digit is:

           

          if(len(variable) = 0) then

          msgbox("PLEASE SET A TEXT")

          else

          exit sub

           

          Good luck

           

          Fernando