My guess is an error with a user defined field on one of those items. I
suggest doing something like this instead of directly accessing the value of
a UDF from its parent item:
Dim objMyProp1 As UserProperty, objMyProp2 As UserProperty
Set objMyProp1 = PatientRecord.UserProperties("MyPropName")
Set objMyProp2 = newPatientRecord.UserProperties("MyPropName")
If Not objMyProp1 Is Nothing Then
If Not objMyProp2 Is Nothing Then
objMyProp2.Value = objMyProp1.Value
Else
Debug.Print Property not found in newPatientRecord!!!!
Stop
End If
Else
Debug.Print Property not found in newPatientRecord!!!!
Stop
End If
The Stop statement will bring you back into the editor if a problem arises
so you can inspect your variables for any problems. You may also want to use
Debug.Assert (Condition) instead, which does not cause a stop if the code is
compiled but does at design time.
You also only need to specify On Error Resume Next only once, unless you
switch to an On Error GoTo # directive.
--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog:
http://blogs.officezealot.com/legault/
"Linn Kubler" wrote:
> Hi,
>
> I had my little application working. It simply copies records from one
> custom public folder to another. I'm mapping differently named user defined
> fields so I wrote all the code out explicitly. The only problem I was
> having was that in 276 items I had two run-time errors and Outlook would
> prompt me to debug or quit. I'd hit debug and then continue and everything
> seemed fine.
>
> I thought it would be a good idea to know which records were causing the
> problem so I read about using the on error resume next statement and
> trapping the error with an If Then statement. Now everything is falling
> apart. I don't get it. Now it traps an error and then every record after
> the first error fails. I now only get about half my items copied, this just
> can't be right. Even worse, when I remove my error trapping code, putting
> back the way it was, I only get 5 records and the rest refuse to save in the
> new table.
>
> How can I figure out what's wrong? Here's the error trapping code I added:
>
> Do While Not PatientRecord Is Nothing
>
> ' Create new record in destination
> Set newPatientRecord = newDeliveriesFolder.Items.Add
>
> ' Populate new record with data
> newPatientRecord.Subject = PatientRecord.Subject
> newPatientRecord.Location = PatientRecord.Location
> newPatientRecord.Start = PatientRecord.Start
>
> On Error Resume Next
> newPatientRecord.Body = PatientRecord.Body
> If Err.Number <> 0 Then
> MsgBox ("Error No.: " & Err.Number & Chr(13) & "Patient Name: " &
> PatientRecord.Subject)
> Err.Clear
> End If
> newPatientRecord.UserProperties.Find("Team").Value =
> PatientRecord.UserProperties.Find("Teams").Value
> newPatientRecord.UserProperties.Find("Therapies").Value =
> PatientRecord.UserProperties.Find("Therapies").Value
> newPatientRecord.UserProperties.Find("Delivery").Value =
> PatientRecord.UserProperties.Find("Delivery").Value
> On Error Resume Next
> newPatientRecord.Save
> If Err.Number = -2147352567 Then
> MsgBox ("Patient Name = " & PatientRecord.Subject)
> Err.Clear
> End If
>
> ' Get next patient in source list
> Set PatientRecord = PatientList.GetNext
> Loop
>
> What am I missing here?
>
> Thanks in advance,
> Linn
>
>
>