473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Basic "For... To... Loop" question

This sub pulls Outlook Appointments into a table.

The problem is I want to limit the import to Location = Boston

I'm not sure how to code that into the For... To loop - As it is now, I get
the following error:

Run-time error '3163':
The field is too small to accept the amount of data you attempted to add.
Try inserting less data.

Any suggestions very welcome!!! Thanks in advance...

Public Sub Import()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblAppointments")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.AppointmentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim iNumApts As Integer
Dim i As Integer
Dim lngEid As Long
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderCalendar)
Set objItems = cf.Items
iNumApts = objItems.Count
If iNumApts <> 0 Then
For i = 1 To iNumApts
If TypeName(objItems(i)) = "AppointmentItem" Then
Set c = objItems(i)
If c.Location = Boston Then
rst.AddNew
rst!Location = c.Location
rst!Date = c.Start
rst!Subject = c.Subject
rst.Update
End If
End If
Next i
rst.Close
End If
End Sub
Nov 12 '05 #1
1 2207
This seems to be working:

Public Sub Import()
On Error GoTo HandleErr
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblAppointments")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.AppointmentItem
Dim objItems As Outlook.Items
Dim varAppt As Variant
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderCalendar)
Set objItems = cf.Items
For Each varAppt In cf.Items
If varAppt.Location <> "United States" And varAppt.Start > Date - 1
Then
rst.AddNew
rst!Location = varAppt.Location
rst!Date = varAppt.Start
rst!Subject = varAppt.Subject
rst.Update
End If
Next
rst.Close
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case 3163
Resume Next
Case Else
MsgBox "Error Number " & Err.Number & ": " & Err.Description
Resume Exit_Here
End Select
End Sub

"deko" <dj****@hotmail.com> wrote in message
news:Na******************@newssvr29.news.prodigy.c om...
This sub pulls Outlook Appointments into a table.

The problem is I want to limit the import to Location = Boston

I'm not sure how to code that into the For... To loop - As it is now, I get the following error:

Run-time error '3163':
The field is too small to accept the amount of data you attempted to add.
Try inserting less data.

Any suggestions very welcome!!! Thanks in advance...

Public Sub Import()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblAppointments")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.AppointmentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim iNumApts As Integer
Dim i As Integer
Dim lngEid As Long
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderCalendar)
Set objItems = cf.Items
iNumApts = objItems.Count
If iNumApts <> 0 Then
For i = 1 To iNumApts
If TypeName(objItems(i)) = "AppointmentItem" Then
Set c = objItems(i)
If c.Location = Boston Then
rst.AddNew
rst!Location = c.Location
rst!Date = c.Start
rst!Subject = c.Subject
rst.Update
End If
End If
Next i
rst.Close
End If
End Sub

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Toby Newman | last post by:
At the page: http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000 or http://tinyurl.com/4ptzs the author warns: "The for loop is frequently used, usually...
4
by: Jacob Rael | last post by:
I am new to python and I love it. I am hacking a file. I want to not print a line if it contains the word 'pmos4_highv'. I also don't want to print the next line. The following code works but it...
3
by: Patrick Sullivan | last post by:
In this for loop, IE skips over the animation function until the end of the loop and only aninmates the last phrase. Firefox does it right. Loop is right below, entire script is below that. This...
15
by: Steve | last post by:
I am having problems getting values out of an array. The array is set as a global array and values are pushed into it as they are read from a JSON file using a "for loop". When the "for loop" is...
9
by: Alexnb | last post by:
Okay, so lets say you have a list: funList = and you do: for x in funList: print x this will print 1-5
0
by: Alexnb | last post by:
Ya just an example, to print the numbers 1-5 Fredrik Lundh wrote: -- View this message in context: http://www.nabble.com/like-a-%22for-loop%22-for-a-string-tp19022098p19022155.html Sent...
3
by: bhavyagupt | last post by:
i 'm not able to use the accordion menu code in for loop . can anyone solve ma problem. code....... slider.js------> java script var slider=function(){ var array=; var speed=10; var...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.