Goal:
From Microsoft Outlook, I want to run append query located in Microsoft Access database, which will create record in "log" table, containing information about sent e-mail. (appending is triggered by event "Application_ItemSend")
Problem:
When I run query, Access appends only two out of seven fields: variable "strSenderEmail" and function "now()" which is inserted in query -> by that I mean that in table "Log" I have only information about sender and date, but subject, receiver etc. are empty.
Additional Info:
- names of the parameters -> I have no information that something is incorrect or missing
- all parameters are input
- I tried to pass parameter alternatively: "qdf.parameters(1)=test" but does not work
- if I run this query from access and insert parameters "from hand" everything works.
Question:
Why is my query not appending properly?
Alternatively I'll try SQL command to insert data or add recordset into table.
Function Code:
strBackendPath - path of backend access
Qapp_001 - name of the append query in access
Set dbs = DBEngine.OpenDatabase(strBackendPath) 'set connection with backend
Set qdf = dbs.QueryDefs(Qapp_001) 'set update merged processes query
<br>
qdf![strSenderEmail] = GetOriginalSenderAddress(objMailItem) 'this is external function, this variable is actually working properly -> information are added in new record
qdf!strReceiverEmail = "test1" 'insert receiver
qdf!strSubject = "test2" 'subject of the e-mail
qdf!struserUID = "test3" '(Environ$("Username"))
qdf!bytCommunicationType = 1 'define type of communication
qdf!bytStatus = 1 'define status
qdf.Execute 'run append query
<br>
Set qdf = Nothing 'clear query
Set dbs = Nothing 'clear database
Columns in Log table:
ID SenderEmail ReceiverEmail Subject PreparationDateAndTime userUID CommunicationType
SQL Code of Append query (from Access):
PARAMETERS
strSenderEmail LongText, strReceiverEmail LongText, strSubject LongText, struserUID Text ( 255 ), bytCommunicationType Byte, bytStatus Byte;
INSERT INTO
Tbl_02_Log ( SenderEmail, ReceiverEmail, Subject, PreparationDateAndTime, userUID, CommunicationType, Status )
SELECT
[strSenderEmail] AS Expr1, [strReceiverEmail] AS Expr2, [strSubject] AS Expr3, Now() AS Expr4, [struserUID] AS Expr5, [bytCommunicationType] AS Expr6, [bytStatus] AS Expr7;