I have been given the task of updating some VBA code in Microsoft Access that the intern before me wrote. What the code currently does is generates an email if an item shows up on a list of items overdue for response. Included in this email is a link to the file's location. The problem that I have to solve is there are four possible folders that this file could be located (four different company locations). Here is the current code, generalized to not reveal internal company information:
Private Sub Command49_Click()
DoCmd.OpenQuery "OverDue", , acReadOnly
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sCCName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("OverDue", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(22)) = False Then
sToName = .Fields(22)
sCCName = "sample@sample.com"
sSubject = "Item That is now Overdue for Response: " & .Fields(0)
sMessageBody = "This Item is now Overdue for a response." & vbNewLine _
& vbNewLine _
& " This is a link to the documents: " & vbNewLine _
& "\\network\shared\Folder1\LOCATION\Folder\Folder\ " & .Fields(0)
DoCmd.SendObject acSendNoObject, , , _
sToName, sCCName, , sSubject, sMessageBody, True, False
End If
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
The part of the link that will have to be changed contingent on location is "LOCATION". I am almost positive that I will have to create another If statement, but I have very minimal coding experience and need assistance doing so. I think that the statement will have to go in the line after "& " This is a link to the documents: " & vbNewLine _ ". I have attempted a couple different If statements, but none of them worked and I did not save them to post here. Any help is greatly appreciated. Thank you.
Aucun commentaire:
Enregistrer un commentaire