Hi All,
i have to export data from notesview to MS-Access is there any one help me out on this… i need your help immedietly…
Thanks
Hi All,
i have to export data from notesview to MS-Access is there any one help me out on this… i need your help immedietly…
Thanks
Subject: Export data
found this code a long time ago, see if this helps you
Options Event:
Option Public
Uselsx “*lsxodbc”
Initialize Event:
'The following agent pushes both BRAND NEW docs and EDITED docs from Notes
to Access.
’ Write to the Contracts table in Access from the Pre Contract Data Sheet
in Notes.
Dim ses As New NotesSession
Dim curdb As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim Con As New ODBCConnection
Dim Qry As New ODBCQuery
Dim Result As New ODBCResultSet
Set Qry.Connection = Con
Set Result.Query = Qry
Con.ConnectTo(“TYPE DATASOURCE HERE”)
’ Access table name we’re pushing to and pulling from.
Qry.SQL = “SELECT * FROM Contracts”
Result.Execute
’ Print a mssg to the status bar to know the connection is good.
If Con.IsConnected Then
Print “Connection to Contracts Established.”
Else
Print “No Connection to Contracts Established.”
Exit Sub
End If
Set curdb = ses.CurrentDatabase
’ Push docs from this view.
Set view = curdb.GetView(“TYPE NOTES VIEW NAME HERE”)
Set doc = view.GetFirstDocument
Do Until (doc Is Nothing)
'If the value of the first (1) field (Contract_No) in the result set (ACCESS)
matches the value in the CTR_TrackingNo field in the first Notes doc in the
view (NOTES), then this doc already exists in Access so push all the following
values in Notes to Access…
If Result.LocateRow(1, doc.CTR_TrackNo(0)) Then
Call Result.SetValue(“Annuitant_Name”, doc.Name(0))
Call Result.SetValue(“Original_Value”, doc.Qte_ActualPrice(0))
Call Result.SetValue(“SCC_Contract_Maturity”,
doc.PC_SccLastDueDt(0))
Call Result.SetValue(“Final_Contract_Maturity”,
doc.Con_Maturity(0))
’ Save to Access.
Result.UpdateRow
Else
’ …Otherwise, if the value of the first (1) field (Contract_No)
in the result set DOES NOT match the value in the CTR_TrackingNo field in the
first Notes doc in the view, then this doc DOES NOT already exist in Access so
create a NEW doc in Access by pushing the following values in Notes to Access.
Result.AddRow
Call Result.SetValue(“Contract_No”, doc.CTR_TrackNo(0))
Call Result.SetValue(“Annuitant_Name”, doc.Name(0))
Call Result.SetValue(“Original_Value”, doc.Qte_ActualPrice(0))
Call Result.SetValue(“SCC_Contract_Maturity”,
doc.PC_SccLastDueDt(0))
Call Result.SetValue(“Final_Contract_Maturity”,
doc.Con_Maturity(0))
’ Save to Access.
Result.UpdateRow
End If
Set doc = view.GetNextDocument(doc)
Loop
’ Close the result set.
Result.Close( DB_CLOSE )
’ Disconnect from the datasource.
Con.Disconnect
Subject: RE: Export data
thanks, Micheal i will check it and get back to you…
thanks for your help