By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Data Type Conversion - How to?

P: n/a
Okay, so I figured out how to pull Outlook Appointments into an Access Table
(see below).

But the data comes in the wrong Data Type - how do I convert it from Text to
Long Integer?

For example, If I have a custom Form in Outlook with and "Entity_ID" field,
this number will come into the table as text - and every time I try to do
something with it, I get "data type mismatch".

Is there an operation I can perform on the table to convert to this data to
Long? There may be text strings that were imported in the Entity_ID field,
and I won't care if that data is lost...

Thanks in advance...
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
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
1st query:

SELECT CLng([Entity_ID]) AS lngEid
FROM tblAppointments;

2nd query:

SELECT tblEntity.Entity_ID FROM tblEntity
WHERE tblEntity.Entity_ID IN (SELECT lngEid FROM qry002);

PROBLEM: getting data type mismatch because some data in tblAppointments was
in fact text (a word, or whatever).

contents of 1st query looks like this:

#ERROR
784
488
483
#ERROR
309
....

How to get rid of the junk that did not convert in 1st query?

Is there s better way to do this?
"deko" <dj****@hotmail.com> wrote in message
news:20*******************@newssvr25.news.prodigy. com...
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below).

But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer?

For example, If I have a custom Form in Outlook with and "Entity_ID" field, this number will come into the table as text - and every time I try to do
something with it, I get "data type mismatch".

Is there an operation I can perform on the table to convert to this data to Long? There may be text strings that were imported in the Entity_ID field, and I won't care if that data is lost...

Thanks in advance...
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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.