imperator
Archaeologist etc.
- Local time
- Today, 09:01
- Joined
- Feb 28, 2004
- Messages
- 38
Hi All
The code below attaches a word doc to an email and works fine:
If recBookingQry("Workshop") = "Facilitated" And recBookingQry("OnSiteOffSite") = 1 Then
.Attachments.Add ("\\barton\home\15311\Museum_Usage_Database\Attachments\Facilitated_Workshop_Visit_Confirmation_Form.doc")
however, I want to replace the path (up to "Attachments...") with a non-specific path based on the CurrentDB path. I'm using this code to try and achieve this:
Public Function GetDBPath() As String
Dim strFullPath As String
Dim I As Integer
strFullPath = CurrentDb().name
For I = Len(strFullPath) To 1 Step -1
If Mid(strFullPath, I, 1) = "\" Then
GetDBPath = Left(strFullPath, I)
Exit For
End If
Next
End Function
?GetDBPath in the immediate window returns:
\\barton\home\15311\Museum Usage Database\
which is good.
but my attempts to use GetDBPath into the attachments path returns an error. Here is my wrong attempt:
.Attachments.Add (GetDBPath & "Attachments\Facilitated_Workshop_Visit_Confirmation_Form.doc")
Can someone point out my error and give me the correct solution?
Many thanks.
The code below attaches a word doc to an email and works fine:
If recBookingQry("Workshop") = "Facilitated" And recBookingQry("OnSiteOffSite") = 1 Then
.Attachments.Add ("\\barton\home\15311\Museum_Usage_Database\Attachments\Facilitated_Workshop_Visit_Confirmation_Form.doc")
however, I want to replace the path (up to "Attachments...") with a non-specific path based on the CurrentDB path. I'm using this code to try and achieve this:
Public Function GetDBPath() As String
Dim strFullPath As String
Dim I As Integer
strFullPath = CurrentDb().name
For I = Len(strFullPath) To 1 Step -1
If Mid(strFullPath, I, 1) = "\" Then
GetDBPath = Left(strFullPath, I)
Exit For
End If
Next
End Function
?GetDBPath in the immediate window returns:
\\barton\home\15311\Museum Usage Database\
which is good.
but my attempts to use GetDBPath into the attachments path returns an error. Here is my wrong attempt:
.Attachments.Add (GetDBPath & "Attachments\Facilitated_Workshop_Visit_Confirmation_Form.doc")
Can someone point out my error and give me the correct solution?
Many thanks.
Last edited: