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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open non-email Lotus Notes Database using VBA

Status
Not open for further replies.

pscribby

Programmer
Aug 20, 2009
5
US
I posted the following on another thread on this site last week, and am following a suggestion to try this forum instead... see below:

pscribby (Programmer)
20 Aug 09 13:22
I am trying to write a VBA module for use inside an MS Access database. Inside the Access dB, I have a claim number. I need to set up a button on my form in Access which, when clicked opens the Claims Database, which is a Lotus Notes Database. I do not need to transfer any data in either direction, I just want to open the Notes database in the client of Lotus Notes, and show the form view for the record (document in Notes terminology) that matches my claim number. I do not know Notes at all. I have managed to enable the Notes objects/classes in Visual Basic, but don't know how to correctly use them. I have the server path, database file name, name of the form inside the Notes dB, and the name of the field on the Notes form (which I need to match to my variable)...
So far, I can only successfully open the Notes database using a shell command. I have a test code module where I have been able to successfully (I think) declare the needed variables, set session, set db, but db.open gives me a "type mismatch" error. Below is the code so far (which isn't working... and I have not added the details to specify the field and search variable yet):

Private Sub test2()

Dim db As Object
Dim dbname As String
Dim dbpath As String
Dim session As Object
Dim view As Object

Set session = CreateObject("Notes.NotesSession")

dbname = "<mydatabase.nsf>"
dbpath = "<myserverpath/>"
Set db = session.GetDatabase(dbpath, dbname)

Set view = db.GetView("<myformname>")

db.Open


End Sub


HughLerwill (Programmer)
21 Aug 09 14:52
I cannot be of much help because I do not have Notes to play with (and do not know much about it) but I think a Google for;

createobject("notes.notesuiworkspace")

may be of help. Most examples are for email from vb code (my main interest) but it seems notesuiworkspace needs to be used to get Notes to display stuff on-screen.

A Google for 'Domino' may give you an object model.

forum9: Lotus/IBM: Domino may be worth a try.

Thank HughLerwill
for this valuable post!



pscribby (Programmer)
26 Aug 09 12:49
Thanks HughLerwill!

I have 2 different paths I experimenting with. One of them includes the notes.notesuiworkspace method that you mentioned. Below is the code so far:

Private Sub test2()

Dim db As Object
Dim dbname As String
Dim dbpath As String
Dim dbfull As String
Dim session As Object
Dim view As Object
Dim doc As Object
Dim docname As String

docname = "<a known good doc number>"

Set session = CreateObject("Notes.NotesSession")

Set uiworkspace = CreateObject("Notes.Notesuiworkspace")

dbname = "<mydbname>"
dbpath = "<mypathname>"
Set db = session.GetDatabase(dbpath, dbname)

Set view = db.GetView("fm_ClaimCase")

End Sub

This code does not throw any errors on debug, and when I run it, no errors appear - but nothing seems to happen either (ie: the notes ui session does not open). I have another approach in which I can successfully open the notes ui workspace using a shell command, but where I get stuck there is that I can't figure out how to specify the view/form and the document I want opened on said view/form... I've Google'd this dozens and dozens of times every which way I can think of... all I keep getting are ways to generate emails from/inside of Notes... nowhere am I finding anything on opening a non-email Notes database... I will also look in the other forum you mentioned to see if somebody there maybe has an idea...
All ideas are appreciated! Thanks!
 
Solution Found!

With the help of a response on another thread, and some additional research, I found the solution. The working code is posted below for anyone who may be looking for a similar solution...

Thanks

Public Function openLegalClaim(legalclaim As String)


Dim dbname As String
Dim dbpath As String
Dim docname As String
Dim notesuiworkspace As Object

docname = legalclaim

Set notesuiworkspace = CreateObject("Notes.Notesuiworkspace")

dbname = "<dbname>"
dbpath = "<dbserverpath>"

Call notesuiworkspace.OpenDatabase(dbpath, dbname, "<viewname>", docname, False, False)



End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top