Thread View: comp.databases.ms-access
1 messages
1 total messages
Started by Ignacio Renuncio
Thu, 18 Nov 1999 00:00
Access97 not refreshing OLE field properly
Author: Ignacio Renuncio
Date: Thu, 18 Nov 1999 00:00
Date: Thu, 18 Nov 1999 00:00
107 lines
5527 bytes
5527 bytes
Hi everybody.
I've been suffering an interesting behaviour in Access97 and would like to
get an explanation for it, maybe it's a documented error.
We have a multiuser document management system coded in Access97 which
stores each document with its associated information in a record, using
standard fields for info and an OLE field for the object itself.
I have recently added a button to one of the forms (one that handles Word
documents) that makes possible to generate an email body with normalized
contents (some of the info fields) and the OLE document as an attachment,
but found some weird problems. The original code of the button is as follows
(some vars and functionality removed to explain the problem clearly, but the
code is self-explanatory):
Private Sub cmdEnviar_Click()
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem
Dim idNewEmail As Long
Dim NewEmailReferencia, NewEmailTo, NewEmailAttn, NewEmailSubject
Dim Tama�oAttachment As Variant
idNewEmail = Me![idComunicacion].Value
NewEmailReferencia = Me![idReferencia]
NewEmailTo = Me![To]
NewEmailAttn = Me![Attn]
NewEmailSubject = Me![Subject]
If NewEmailReferencia = 0 Or Nz(NewEmailTo, "") = "" Or Nz(NewEmailAttn,
"") = "" Or Nz(NewEmailSubject, "") = "" Or IsNull(Objeto) Then
MsgBox "One or more fields are empty, or the document is null",
vbExclamation, "Warning"
Else
' If not, first of all we save the record
DoCmd.RunCommand acCmdSaveRecord
' And automatically create an email as specified
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
If chkIncluirTiposDeLetra = True Then
Objeto.Object.EmbedTrueTypeFonts = True
Objeto.Object.SaveSubsetFonts = True
chkIncluirTiposDeLetra = False
Else
Objeto.Object.EmbedTrueTypeFonts = False
End If
Objeto.Object.Application.Options.BackgroundSave = False
Objeto.Object.Application.Options.AllowFastSave = True
Objeto.Object.SaveAs "T:\Email #" & idNewEmail & ".doc",
wdFormatDocument
' Here we show a new form to select the To & CC values for the new
email
DoCmd.OpenForm "ListaDestinatarios"
newMail.To = ListaDestinatariosCampoTo
newMail.CC = ListaDestinatariosCampoCC
newMail.Subject = "Email message #" & idNewEmail & " (" &
NewEmailSubject & ")"
newMail.OriginatorDeliveryReportRequested = True
newMail.DeleteAfterSubmit = True
newMail.HTMLBody = "<p align=""center"">Some normalized messages
here</p>"
newMail.Attachments.Add "T:\Email #" & idNewEmail & ".doc",
olByValue
Kill "T:\Email #" & idNewEmail & ".doc"
newMail.Display
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End If
End Sub
Well, some of the generated emails had an empty attchment. At first sight I
thought it was due to some kind of timeout, like Word saving in the
background and thus Access97 could execute the newMail.Attahments.Add before
the file was completely saved, so I double-checked the
"BackgroundSave=True" line. The bug remained, so I even thought Word could
have a bug, returning control to the caller before having completed the
BackgroundSave process.
After some additional thinking and experimentation, the main problem seems
to have its roots in Access97, and it only happens when I'm creating a new
record and generating a new email from it, not when I generate an email for
an old record. It seems that Access does not save the OLE field properly
when I execute the acCmdSaveRecord because of some unknown reason.
Everything is working ok since I added the following line:
' If not, first of all we save the record
DoCmd.RunCommand acCmdSaveRecord
' --------> THIS ONE <-------- Now the app runs ok, but WHY DOES
ACCESS NEED THIS?
Me.Refresh
' And automatically create an email as specified
Set ns = ol.GetNamespace("MAPI")
So you know the full story. I'd like to read some opinions regarding this,
if somebody has experienced it before, and what is the reason for this
behaviour.
TIA 1E+06
----------
Ignacio Renuncio
Systems Administrator / Developer
SPARE, S.A. (SPAIN)
Phone: +34 944523200
Fax: +34 944523030
Work email: irenuncio@spare.youshoulddeletethis.es
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads