S
Simon Shaw
Dear Experts,
I am trying to experiment with keeping extended information about Outlook
items in an Access database, for a posisble training application. My first
test was to link a contact item to a table in an MDB. Already I seem to be
having difficulties :-(
In the example below, I am (successfully) getting the next available
autonumber ID from the access db, and then trying to assign it to a user
property of the contact item. But for some reason, the assignment does not
succeed, and no error is returned.
Any ideas?
TIA
Simon Shaw
<Code Starts>
Public Sub trainer_open()
Dim rs As DAO.Recordset
Dim myItem As Object
Dim Property As UserProperty
Dim ID As Long
Set db = OpenDatabase(strDBPath)
Set myItem = Application.ActiveInspector.CurrentItem
' this might be a new one - check to see if TrainerID already set
ID = 0
For Each Property In myItem.UserProperties
If Property.Name = "TrainerID" Then
ID = CInt(Property.Value)
End If
Next
If ID = 0 Then ' its new
Set rs = db.OpenRecordset("SELECT * FROM Trainer WHERE 1=0",
dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs.Update
rs.MoveFirst
myItem.UserProperties("TrainerID") = CStr(rs!TrainerID)
myItem.Save
End If
rs.Close
Set rs = Nothing
End Sub
I am trying to experiment with keeping extended information about Outlook
items in an Access database, for a posisble training application. My first
test was to link a contact item to a table in an MDB. Already I seem to be
having difficulties :-(
In the example below, I am (successfully) getting the next available
autonumber ID from the access db, and then trying to assign it to a user
property of the contact item. But for some reason, the assignment does not
succeed, and no error is returned.
Any ideas?
TIA
Simon Shaw
<Code Starts>
Public Sub trainer_open()
Dim rs As DAO.Recordset
Dim myItem As Object
Dim Property As UserProperty
Dim ID As Long
Set db = OpenDatabase(strDBPath)
Set myItem = Application.ActiveInspector.CurrentItem
' this might be a new one - check to see if TrainerID already set
ID = 0
For Each Property In myItem.UserProperties
If Property.Name = "TrainerID" Then
ID = CInt(Property.Value)
End If
Next
If ID = 0 Then ' its new
Set rs = db.OpenRecordset("SELECT * FROM Trainer WHERE 1=0",
dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs.Update
rs.MoveFirst
myItem.UserProperties("TrainerID") = CStr(rs!TrainerID)
myItem.Save
End If
rs.Close
Set rs = Nothing
End Sub