ActivexX InputBox

Hi,

In ActiveX, is there a way to take imput from user and then do some validation.  User can click on eithere OK or CANCEL to proceed or quit DTS?  Thx
mcrmgAsked:
Who is Participating?
 
patriktConnect With a Mentor Commented:
Code sample:

First ActiveX script.It takes value and validates it. If valid it goes to next step.

Function Main()
      Value=InputBox("Give me value", 0  )
      If Value>12 or Value<1 Then
            Main=DTSTaskExecResult_Failure
      else
            DTSGlobalVariables("Month").Value=Value
            Main = DTSTaskExecResult_Success
      end if
            
End Function

Secon ActiveX script. It displays value and by user response it results as Success or failure.

Function Main()
      OK=MsgBox( "This is correct value:" + DTSGlobalVariables("Month").Value,  vbYesNo)
      If OK=vbYes Then
            Main = DTSTaskExecResult_Success
      ELSE
            Main =DTSTaskExecResult_Failure
      end if
End Function

For value storrage it uses Global variable "Month". You define global variables in package properties.

Patrik
0
 
patriktCommented:
Who do you suppose is user? DTS package is running on server in server service context. It has no user interface and no user to ask.

Patrik
0
 
mcrmgAuthor Commented:
lol............

You are right........ I meant the person who use this DTS.... (in this case, it would be me........)

Sorry for the confusion...
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Anthony PerkinsCommented:
Add an ActiveX script and use something like this:

Function Main()
Dim Value
Dim IsValid

Value = InputBox("Enter value here", "")
'  Do validation here and set the IsValid variable appropriately

If IsValid Then
      Main = DTSTaskExecResult_Success
Else
      Main = DTSTaskExecResult_Failure
End If

End Function

Then set your Workflow to only proceed if the previous task is successful.

And finally, don't even attempt to schedule this DTS package :)
0
 
mcrmgAuthor Commented:
This is what I try to do, something like this:

When I enter a value, say, 9

it will take that 9 and show in msgbox, say, September

If I click on OK, DTS will proceed, if I clcik on CANCEL, DTS will quit. possible?  Thx

0
 
Anthony PerkinsConnect With a Mentor Commented:
>>If I click on OK, DTS will proceed, if I clcik on CANCEL, DTS will quit. possible? <<
Yes.  Something like this:

Function Main()
Dim Value
Dim IsValid

IsValid = False

Value = Trim(InputBox("Enter value here", ""))
If IsNumeric(Value) Then
   If Len(Value) <= 2 Then
      If Value >= 1 And Value <= 12 Then
         If MsgBox("Did you really want " & MonthName(Value) & "?", vbYesNo) = vbYes Then
            IsValid = True
         End If
      End If
   End If
End If

If IsValid Then
     Main = DTSTaskExecResult_Success
Else
     Main = DTSTaskExecResult_Failure
End If

End Function
0
 
mcrmgAuthor Commented:
Hi,

I was trying the code, then for some reason that I can not find the panel that I can put in the code.  When double click on Activex in dts, it pops up ActiveX Script Task Properties, How can I open the panel that I can write the code?  Thx
0
 
mcrmgAuthor Commented:
usually, there is "language" on left hand side, and a panel for coding on right hand side, the one on right hand side disappeared.......
0
 
Anthony PerkinsCommented:
>>When double click on Activex in dts, it pops up ActiveX Script Task Properties, How can I open the panel that I can write the code?<<
No idea what could be happening.  I just created a new package and single clicked on the ActiveX Script Task icon on the left and the new window opened to enter the code.
0
 
mcrmgAuthor Commented:
very strange, if I work on the server directly, it is fine.  But if I open it on client, I do not have edit area.......
0
 
Anthony PerkinsConnect With a Mentor Commented:
Not sure.  Perhaps it is time to re-install the client components.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.