473,750 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OpenR ecordset("tblAp pointments")
Dim ol As New Outlook.Applica tion
Dim olns As Outlook.Namespa ce
Dim cf As Outlook.MAPIFol der
Dim c As Outlook.Appoint mentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserPro perty
Dim iNumApts As Integer
Dim i As Integer
Dim lngEid As Long
Set olns = ol.GetNamespace ("MAPI")
Set cf = olns.GetDefault Folder(olFolder Calendar)
Set objItems = cf.Items
iNumApts = objItems.Count
If iNumApts <> 0 Then
For i = 1 To iNumApts
If TypeName(objIte ms(i)) = "AppointmentIte m" 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 2234
This seems to be working:

Public Sub Import()
On Error GoTo HandleErr
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenR ecordset("tblAp pointments")
Dim ol As New Outlook.Applica tion
Dim olns As Outlook.Namespa ce
Dim cf As Outlook.MAPIFol der
Dim c As Outlook.Appoint mentItem
Dim objItems As Outlook.Items
Dim varAppt As Variant
Set olns = ol.GetNamespace ("MAPI")
Set cf = olns.GetDefault Folder(olFolder Calendar)
Set objItems = cf.Items
For Each varAppt In cf.Items
If varAppt.Locatio n <> "United States" And varAppt.Start > Date - 1
Then
rst.AddNew
rst!Location = varAppt.Locatio n
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******** **********@news svr29.news.prod igy.com...
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.OpenR ecordset("tblAp pointments")
Dim ol As New Outlook.Applica tion
Dim olns As Outlook.Namespa ce
Dim cf As Outlook.MAPIFol der
Dim c As Outlook.Appoint mentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserPro perty
Dim iNumApts As Integer
Dim i As Integer
Dim lngEid As Long
Set olns = ol.GetNamespace ("MAPI")
Set cf = olns.GetDefault Folder(olFolder Calendar)
Set objItems = cf.Items
iNumApts = objItems.Count
If iNumApts <> 0 Then
For i = 1 To iNumApts
If TypeName(objIte ms(i)) = "AppointmentIte m" 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
4654
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 where the loop will be traversed a fixed number of times. It is very flexible, and novice programmers should take care not to abuse the power it offers."
4
4724
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 "smells bad" and just doesn't look right. I was reading about generators. If I was using one, I could do a .next() after the match and get rid of the flags. Any suggestions how I can improve this? inPmos = False
3
2251
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 script uses the Yahoo GUI library (beta) for animation. for (var c=0; c < index; c++) { document.getElementById("sample").innerText = myArray; var myanim = new YAHOO.util.Anim('sample', { fontSize: {from: 0, to: 50}, opacity: {from: 0.5, to: 1}
15
2365
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 finished I want to convert the array into a string which can be used by another function. My attempt to do this is not working. The script looks like this: heights=; function getElevationInter(latv,lngv) { var script =...
9
1567
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
156
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 from the Python - python-list mailing list archive at Nabble.com.
3
2411
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 timer=10; return{ init:function(t,c){
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.