The below snippet is part of a bigger piece of code. Essentially, I'm trying to transform the code to make it more versatile.
To this end, rather than having values hard-coded in the VBA, I'd like for the VBA to read those values from a table. I'd like the code to loop through the table's column until there is a blank field in the relevant column, and at that point, stop looping.
Assume I have a table "Word" and two columns: "Match" and "Extra Info." I'd like the VBA to read from column Match. If there is no value, the script ends. If there is a value, and that value matches what the VBA is comparing against, then the code reads the data from the corresponding field "Extra Info" and writes it to another field.
Below is the example of how it works now, without this dynamic behavior. For reference, the VBA is reading an Outlook .msg file:
So, I'd like TC and TR to pull from table Word, column Match. If there is a match in the email's msg.body, then Me.Description = table Word, column Extra Info.
I thought I could do an if isnull on the match field- if true, end the script, and if false, then do Dlookup. But I'm having problems with the if null working, and also don't know how to iterate that well.
I'd immensely appreciate any help or guidance I could get on this.
Thank you so much!!
To this end, rather than having values hard-coded in the VBA, I'd like for the VBA to read those values from a table. I'd like the code to loop through the table's column until there is a blank field in the relevant column, and at that point, stop looping.
Assume I have a table "Word" and two columns: "Match" and "Extra Info." I'd like the VBA to read from column Match. If there is no value, the script ends. If there is a value, and that value matches what the VBA is comparing against, then the code reads the data from the corresponding field "Extra Info" and writes it to another field.
Below is the example of how it works now, without this dynamic behavior. For reference, the VBA is reading an Outlook .msg file:
Code:
'This command below will search the email body for the following words and if found, insert them into the Access field "Description"
'Round 1
If InStr(msg.Subject, "TC> 0 Or InStr(msg.body, "TC") > 0 Then
Me.Description = "TC Extra Info: " & strTicket
End If
'Round 2
ElseIf InStr(msg.Subject, "TR") > 0 Or InStr(msg.body, "R") > 0 Then
Me.Description = "TR Extra Info"
End
End If
So, I'd like TC and TR to pull from table Word, column Match. If there is a match in the email's msg.body, then Me.Description = table Word, column Extra Info.
I thought I could do an if isnull on the match field- if true, end the script, and if false, then do Dlookup. But I'm having problems with the if null working, and also don't know how to iterate that well.
I'd immensely appreciate any help or guidance I could get on this.
Thank you so much!!