I got part of this from another post. What I’m trying to do is have 2 prompts come up for the user to choose from then create a doc and show all the values. The form has text fields setup correctly to use on the new doc.
I need some help with my code. I saw two different codes with what I need but I’m having a hard time combining them.
Thanks for any help!
Sub Click(Source As Button)
'dim and set the objects
Dim session As New notessession
Dim dbCurr As notesdatabase
Set dbCurr = session.currentdatabase
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Dim docCurr As NotesDocument
Dim pickDoc As notesdocument
Set uidoc = ws.currentdocument
Dim newuidoc As notesuidocument
Set docCurr = uidoc.document
Dim getdoctitle As Variant, doctitle As String
Dim yearnums(3) As Variant
Dim yearvals(3)
Dim i As Integer
Dim pickview As notesview
Set pickview = dbCurr.getview("ShowLocation")
Dim a(300) As String,b(300) As String,c(300) As String,d(300) As String
Dim e(300) As String,f(300) As String
'what year do they want, present list of one year before current year, current year, and one year after
'or alternatively give them a picklist of year view
YearNow = Year(Today)
yearnums(0) = YearNow + (-1)
yearnums(1) = YearNow
yearnums(2) = YearNow + 1
For i = 0 To 2
yearvals(i) = Cstr(yearnums(i)) 'convert the years to a string so that we can present it
Next
'give them the view to choose a document from
server = dbCurr.server
dbname = dbCurr.FileName
viewname = "showlocation"
'give them a list of documents for selection
picklist = ws.Pickliststrings(3,1,server,dbname,viewname, "OSHA Form 300","Select a Location.",3,"")
If Isempty(picklist) Then Exit Sub 'they have pressed cancel
location = picklist(0)
whichyear = ws.Prompt( PROMPT_OKCANCELLIST, "OSHA Form 300", "What year do you want to view?", yearvals(1), yearvals)
If whichyear = "" Then
'they have pressed cancel
Exit Sub
End If
temp1 = Strleft(location, "^")
temp2 = Strright(location, "^")
'create the document and open it
Dim OSHA300form As NotesDocument
Set OSHA300form = dbCurr.CreateDocument
OSHA300form.Form = "OSHA300form"
Set doc = collection.GetFirstDocument
Do Until doc Is Nothing
OSHA300form.selection = temp1 & "~" & whichyear
OSHA300form.formloc = temp1
OSHA300form.formyr = whichyear
OSHA300form.formstate = temp2
OSHA300form.a = CaseLog
OSHA300form.b = EmpFullName
OSHA300form.c = EmpJobTitle
OSHA300form.d = CaseDate
OSHA300form.e = CaseWhereOccurred
OSHA300form.f = CaseInjuryorIllnes
End If
Next
Set doc = collection.GetNextDocument(doc)
Loop
Set NewUIDoc = ws.EditDocument(False, OSHA300form)
End If
End Sub