L
Linn Kubler
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
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