Hi Darbid
My daughter boyfriend was round this weekend - who is a programmer. He has managed to get the project working, though there are still 2 issues remaining. I don't kniw if i should start a new post for them?
But for anyone following this link, here is the code that works along with the two issues that he didn't manage to resolve as we ran out of time.
In outlook the code is:
Private Sub emTool()
Dim accessApp As Access.Application, outlookApp As Outlook.Application
Dim outlookNamespace As Object, outlookFolder As Object, outlookMail As Object
Set outlookApp = CreateObject("Outlook.Application")
Set accessApp = CreateObject("Access.Application")
Set outlookNamespace = outlookApp.GetNamespace("MAPI")
Set outlookFolder = outlookNamespace.GetDefaultFolder(olFolderInbox)
Set outlookMail = outlookFolder.Items(7)
accessApp.OpenCurrentDatabase "C:\flicks database.accdb", False
accessApp.Run "ReceiveEmailFromOutlook", outlookMail.SenderEmailAddress
Set accessApp = Nothing
Set outlookApp = Nothing
End Sub
In the database the module code is:
Public Sub ReceiveEmailFromOutlook(ByVal emailAddress As String)
Dim database As DAO.database, record As DAO.Recordset, list As String, PromoterID As String
Dim strFilter As String
Set database = CurrentDb
Set record = database.OpenRecordset("SELECT ID FROM dbo_Promoters WHERE email = '" & emailAddress & "'", dbOpenDynaset, [dbSeeChanges])
PromoterID = record.Fields(0)
strFilter = "[PromoterID] = " & record.Fields(0)
DoCmd.ApplyFilter , strFilter
End Sub
(for anyone wanting to use this don't call the module the same name as routine! this may be obvious to many of you but it took me ages to work out that was a problem.)
So, although this code works there are two main problems:
this code only selects a particular email (7th on the list), rather than the currently highlighted email.
The second problem is that is keep opening a new copy of access rather than using the existing opened copy!
Many thanks for all your help Darbid.