Creating a document from Database A to Database B

Hi all, i urgently need help in solving this problem that i’m encountering. Please help me with a solution.

This is my scenario…

I have this Database A, when a btn is click. A document in Database B will be created. and some fields in the Database A will need to show in the document in Database B…

Anyone has a sample code that do something like this…

Basically i just need to export the information from Database A to Database B… but i not sure how to go about doing it…

Please help… I hope my explaination is clear… thanks :slight_smile:

Subject: Creating a document from Database A to Database B

dim uiw as new notesuiworkspacedim session as new notessession

dim currentdb as notesdatabase

dim otherdb as notesdatabase

dim currentdoc as notesdocument

dim otherdoc as notesdocument

set currentdoc = uiw.currentDocument.document

set currentdb = currentdoc.parentdatabase

set otherdb = session.getdatabase(server,dbpath)

set otherdoc = new notesdocument(otherdb)

'now set the field values

otherdoc.fieldname = currentdoc.fieldname

and so on…

and so on…

call otherdoc.save

Bernhard

Subject: RE: Creating a document from Database A to Database B

Hi Yong,

Bernanrds solution is good, but to add a few points.

Just add the exception handling logic to the code. Once database is set, look for the existence or a valid handle for the database.

e.g. set otherdb=session.GetDatabase(Server,Path)

'now check for database existence

If not(otherdb.IsOpen) then

Msgbox “The target database cannot be opened. Exiting.”

End If

in the above code, you may quit processing, if you cant get a valid handle to the target database. You can use.

Continue=false 'where continue is of data type variant

Exit Sub

Or whatever you wish. This puts up a good practice. Similarly you can do exception handling for NotesView, NotesDocument.

Regards,

Jason

Subject: RE: Creating a document from Database A to Database B

Hi thank you very much for the help… let me try it out and see whether i can get things right… because i’m new to lotus notes… so seems like not getting the things correct… i hope i can count on both of you if i still get things stuck.

okie?

regards… wei xiang