LotusScript "If" Help

The problem with this script is that it will create a response doc for the first if statement but not the second. There is a value in the Date2 fiels so the formula should continue.

Please Help!

Sub Initialize

Dim s As New notessession

Dim db As notesdatabase

Dim uiws As New notesuiworkspace

Dim mainDoc As notesdocument

Dim responseDoc As notesdocument

Dim Date1 As String

Dim Date2 As String

Dim i As Integer

Dim Lab As String

Set db = s.currentdatabase

Set responseDoc = db.createdocument

Set mainDoc uiws.currentdocument.document

Set responseDoc = db.createdocument





If Lab1 = "Fab Ops" & Date1 <> "" Then  

	Call responseDoc.makeresponse(mainDoc)

	responseDoc.form = "FO"

	responseDoc.Week = "W1"

	Call responseDoc.save(True,True) 

End If



If Lab1 = "Fab Ops" & Date2 <> "" Then  

	Call responseDoc.makeresponse(mainDoc)

	responseDoc.form = "FO"

	responseDoc.Week = "W2"

	Call responseDoc.save(True,True)

End If

Subject: You made my most common mistake!

You confused the formula language & for the LotusScript “and”

“&” in LS means to concatenate.

Howard

Subject: LotusScript “If” Help

You never created the second response document.

Try this:

Dim s As New notessession

Dim db As notesdatabase

Dim uiws As New notesuiworkspace

dim uidoc as NotesUIDocument

set uidoc=ws.currentdocument

Dim mainDoc As notesdocument

set MainDoc as NotesDocument

Dim responseDoc As notesdocument

%REM

Not sure what you are doing with these

Dim Date1 As String

Dim Date2 As String

Dim i As Integer

Dim Lab As String

%ENDREM

Set db = s.currentdatabase

If Lab1 = “Fab Ops” then

If Maindoc.Date1(0) <> “” Then

Set responseDoc = db.createdocument

Call responseDoc.makeresponse(mainDoc)

responseDoc.form = “FO”

responseDoc.Week = “W1”

Call responseDoc.save(True,True)

End If

If Maindoc.Date2(0) <> “” Then

Set responseDoc = db.createdocument

Call responseDoc.makeresponse(mainDoc)

responseDoc.form = “FO”

responseDoc.Week = “W2”

Call responseDoc.save(True,True)

else

exit sub

End If

Subject: LotusScript “If” Help

You never created the second response document.

Try this:

Dim s As New notessession

Dim db As notesdatabase

Dim uiws As New notesuiworkspace

dim uidoc as NotesUIDocument

set uidoc=ws.currentdocument

Dim mainDoc As notesdocument

set MainDoc as NotesDocument

Dim responseDoc As notesdocument

%REM

Not sure what you are doing with these

Dim Date1 As String

Dim Date2 As String

Dim i As Integer

Dim Lab As String

%ENDREM

Set db = s.currentdatabase

If Lab1 = “Fab Ops” then

If Maindoc.Date1(0) <> “” Then

Set responseDoc = db.createdocument

Call responseDoc.makeresponse(mainDoc)

responseDoc.form = “FO”

responseDoc.Week = “W1”

Call responseDoc.save(True,True)

End If

If Maindoc.Date2(0) <> “” Then

Set responseDoc = db.createdocument

Call responseDoc.makeresponse(mainDoc)

responseDoc.form = “FO”

responseDoc.Week = “W2”

Call responseDoc.save(True,True)

else

exit sub

End If

Subject: Where are you setting the values for Lab1, Date1 and Date2? Your code does not show this.

Subject: LotusScript “If” Help

It probably is executing the second set of statements. But you are not creating a second document there. So it is just executing the code against the same document you manipulated in the first block. I bet if you look at the one document that is created you will see that week = W2.

Good Luck,

Rob