Link to home
Start Free TrialLog in
Avatar of jforget1
jforget1

asked on

"Variant does not contain a container" error

I  am getting an "Variant does not contain a container" error. How do I give my new code a container, just want to help it out. :>)

Sub Click(Source As Button)
     Dim s As New notessession
     Dim db As notesdatabase
     Set db = s.currentdatabase
     Dim ws As New notesuiworkspace
     Dim uiDoc As notesuiDocument
     Set uiDoc = ws.currentdocument
     Dim tmpArr As Variant
     
     Call s.SetEnvironmentVar("WindowSizePickKeywords", "171 142 736 553", True)
     tmpArr = ws.PickListstrings( 3, False, db.server , db.fileName , "PayrollTitles" , "Payroll Titles" , "Please choose a payroll title for this user.", 1, "")
     Call uiDoc.fieldsettext("payroll_title", tmpArr(0))
     
End Sub
Avatar of SysExpert
SysExpert
Flag of Israel image

On what line is the  error occurri ?

Have you run this in  debug Mode ?

I hope this helps !
Some suggestions:
- you do this in a document that's open for editing??
- use db.FilePath, not db.FileName
Avatar of jforget1
jforget1

ASKER

Sorry, forgot to add that, it is happening at the line below. Maybe because there is nothing to put into the field.

Call uiDoc.fieldsettext("payroll_title", tmpArr(0))
" you do this in a document that's open for editing??"

Yes it is in edit mode.
tmpArr(0) may not have value.
so.. before Call uiDoc.fieldsettext("payroll_title", tmpArr(0)) this, add..

if (isempty(tmpArr)) then
msgbox "Please select value"
exit sub
end if
What if they just want to cancel and not choose a value, will this code help that.
yes..it will help
I added the code suggested but still get the error when hitting cancel, do I have this in the proper place?

Sub Click(Source As Button)
      Dim s As New notessession
      Dim db As notesdatabase
      Set db = s.currentdatabase
      Dim ws As New notesuiworkspace
      Dim uiDoc As notesuiDocument
      Set uiDoc = ws.currentdocument
      Dim tmpArr As Variant
      
      Call s.SetEnvironmentVar("WindowSizePickKeywords", "171 142 736 553", True)
      tmpArr = ws.PickListstrings( 3, False, db.server , db.filePath , "PayrollTitles" , "Payroll Titles" , "Please choose a payroll title for this user.", 1, "")
      Call uiDoc.fieldsettext("payroll_title", tmpArr(0))
      If (Isempty(tmpArr)) Then
            Msgbox "Please select value or Cancel"            
            Exit Sub
      End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This worked, I ended up taking out the MsgBox but the rest of the code worked. Thanks for the help.