Domino Code Fragment

Code Name*
GetTarget Function: Gets target db as current db.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.149.27.202
Description*
Given the current database and a new filename will return that filename as the new current database if it is on the same server and path.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

'-- Restrictions target must reside in same server and path
'-- This function takes in the current database and a target database filename to open the target database on
'-- same server and path.
'-- Use this function for inter-database access for those database's that are part of the same application suite

'-- Pass the current db to "dbNewCur" parameter, Pass the new database filename to the "sNewFileName" (including
'-- the .nsf extension) parameter
'-- Returns the target database as type NotesDatabase.

Function GetTarget(dbNewCur As notesdatabase, sNewFileName As String) As NotesDatabase
Dim nGetbeginFilename As Integer
'-- Assign Current Database FilePath to sFilePath variable
sFilePath = dbNewCur.FilePath
'-- Assign Current Database FileName to sFileName variable
sFileName = dbNewCur.FileName
'-- Find start of sFileName in sFilePath and assign to nGetbeginFilename variable
nGetbeginFilename = Instr(1, sFilePath, sFileName)
'-- Parse sFileName from sFilePath and assign to sFilePath variable
sFilePath = Mid$(sFilePath, 1, nGetbeginFilename - 1)
'-- Get Server name if not local
sGetServer = dbNewCur.Server

'The final code fragment is used to access the database using the New method in the NotesDatabase class.
'The first sGetServer parameter indicates server being accessed and the second parameter passes the
'-- appropriate database path & filename
'-- Access target database using current server and path with target db name

Dim dbTemp As New notesdatabase(sGetServer, sFilePath & sNewFileName)
'-- assign target db for function return to calling program
Set GetTarget = dbTemp
End Function