query of Lotus DB - only specific records

Self_Taught

New Member
Joined
Nov 20, 2013
Messages
6
I'm using VBA to query a Lotus db and it works but so far I can only get it to pull all records in the specified view. Anyone have an idea how I could get this to pull only records where a specific field met certain criteria?

For example... In the code below I would only want to pull records where Value02 was not null




Private Sub CommandButton1_Click()
Dim Ans, session, db, View, doc, i, strShtName, Value01, Value02

Ans = MsgBox("Proceed?", vbYesNo, "Confirm")
Select Case Ans
Case vbNo
Exit Sub
End Select

Set session = CreateObject("Notes.NotesSession")
'##### define Notes server and file path
Set db = session.GetDatabase("server", "dir\file.nsf")
'##### get Notes view
Set View = db.getView("view01")

i = 2
Set strShtName = ActiveSheet
Set doc = View.GetFirstDocument
Do Until doc Is Nothing
Value01 = doc.GetItemValue("DB_Value01")
Value02 = doc.GetItemValue("DB_Value02")

strShtName.Cells(i, 2) = Value01(0)
strShtName.Cells(i, 3) = Value02(0)

Set doc = View.GetNextDocument(doc)
i = i + 1
Loop

strShtName.Range(Cells(2, 1), Cells(i, 3)) _
.Sort Key1:=strShtName.Cells(1, 3), order1:=xlAscending, _
Key2:=strShtName.Cells(1, 2), order2:=xlAscending

MsgBox "Finish!"
End Sub
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top