Hi All, I have a tblImportedEmail field [Emailbody] that contains text with a BookingRef also I have a tblbookings that holds [BookingRef] I wanted access to go through the Emailbody and match it to the [BookingRef] in the tblbookings
As all the BookingRef are in different formats and rarely have any pre-set identifiers eg : or # instr isn’t an option so I believe SELECT DISTINCT would work based from an old code example nschroeder.
I have to admit I just can’t get to the back of this one. Can somebody give me a push in the right direction.
Thanks
FAB1
As all the BookingRef are in different formats and rarely have any pre-set identifiers eg : or # instr isn’t an option so I believe SELECT DISTINCT would work based from an old code example nschroeder.
I have to admit I just can’t get to the back of this one. Can somebody give me a push in the right direction.
Thanks
FAB1
PHP:
Option Compare Database
Dim db As Database
Dim rsFindBookingID As Recordset
Dim aInput() As String
Dim strWord As String
Dim a As Integer
Dim strBookingIDQry As String
Private Sub cmdBTSearch_Click()
'Clean up Emailbody and split into single lines
strTxtVal = Me.EmailBody
strTxtVal = Replace(strTxtVal, ".", "") ' Repeat for other characters as needed
strTxtVal = Replace(strTxtVal, Chr(10), "") ' remove CR
strTxtVal = Replace(strTxtVal, Chr(13), "") ' remove LF
aInput = Split(strTxtVal, " ")
For a = 0 To UBound(aInput)
strWord = aInput(a)
Me.Refresh
Next
'Check that text has been cleaned
' MsgBox (strWord)
strBookingIDQry = "SELECT DISTINCT tblBookings.BookingID, tblBookings.FolioID, tblBookings.SupplierID " & _
"FROM tblbookings " & _
"WHERE tblbookings.BookingRef=""" & strWord & """;"
Set rsFindBookingID = db.OpenRecordset(strBookingIDQry)
With rsFindBookingID
If .RecordCount = 0 Then
MsgBox "No Match"
Else
txtMatchedBookingRef = !BookingRef
txtMatchedBookingID = !BookingID
txtMatchedFolioID = !FolioID
txtMatchedSupplierID = !SupplierID
End If
End With
Set rsFindBookingID = Nothing
End Sub
Private Sub Form_Close()
Set db = Nothing
End Sub
Private Sub Form_Open(Cancel As Integer)
Set db = CurrentDb()
End Sub