Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Arrays

Status
Not open for further replies.

swaybright

Technical User
Jun 25, 2003
156
US
Hi All,

I am trying to build a dynamic array and thought I had it licked. But my code puts the built array into the first slot of the array (not too surprising). I'm trying to get around that problem any suggestions? See my code for what I'm trying to do.

Thanks!
Shane

Public Function GetAllTSR()
Dim session As Object
Dim db As Object
Dim view As Object
Dim doc As Object
Dim NameCtr As Long
Dim ViewStr As String
Dim FieldValue As Variant
Dim AllFV As String
Dim NFS, NFD As Variant
Dim NFNS, NFND As Variant
Dim EntryNo As Integer

'array to send field names to LotusNotes
NFNS = Array("TSRNumber", "Form", "StandardAdditive", "A01", "A01Level", _
"A02", "A02Level", "Acid", "AcidLevel", "Mixing", "Compounding", _
"MeshScreen", "Zone1F", "Zone2F", "Zone3F", "DieZoneF", "ScrewSpeed", _
"Molding", "BarrelTemp1C", "BarrelTemp2C", "DieTempC")
If fIsAppRunning = False Then
MsgBox "Lotus Notes is not running" & Chr$(10) _
& "Make sure Lotus Notes is running and you have logged on."
Exit Function
End If

ViewStr = "3. R&D\By Period"

'open Notes and set document to get field values
Set session = CreateObject("Notes.NotesSession")
Set db = session.GetDatabase("servername", "user\chemical\millad.nsf")
Set view = db.GetView(ViewStr)
Set doc = view.GetFirstDocument

'Here begins the dynamic array
'I want each fieldvalue to be a new array parameter
AllFV = ""
For NameCtr = 0 To UBound(NFNS) 'get value for each field name in NFNS array
FieldValue = doc.GetItemValue(NFNS(NameCtr)) 'get value
'construct string that will be the array
AllFV = AllFV & ", " & Chr(34) & FieldValue(0) & Chr(34)
Next NameCtr

'strip off the comma and space at beginning
AllFV = Mid(AllFV, 3)
'This doesnt put the text1, text2, text3...,text20 like I want
' it treats the string as slot 1 only--shocker
NFS = Array(AllFV)


MsgBox "The value in " & NFNS(0) & " is " & NFS(0), vbOKOnly, "LotusNotes Value"

End Function
 
I sorted it out with a little help from the help file.
Another question: I am going to use the NFS array values as values in an append sql statement, do I need to put quotes around them?
Thanks
Shane

Dim NFS(20) as Variant
.
.
.
For NameCtr = 0 To 20
FieldValue = doc.GetItemValue(NFNS(NameCtr))
NFS(NameCtr) = FieldValue(0)
Next NameCtr

MsgBox "The value in " & NFNS(2) & " is " & NFS(2), vbOKOnly, "LotusNotes Value"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top