D
DoctorV3774
I have the following module which allows me to attach a file path into a
field of my form. This works fine if the field is null. However if the
field is already populated it will not let me add an additional file path for
an attachment. how can i modify this code so I can attach multiple files to
the field? Thanks
****************CODE****************
Function InsertNewFile()
Dim FileName As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to insert an attachment?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Warning" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
On Error GoTo err_showSendDialog
Dim CurrentAttach As String
If Response = vbYes Then ' User chose Yes.
'[Forms]![MyWorkspace]![LPID]
[Forms]![MyWorkspace]![EmailAttachment].Locked = False
FileName = FileToOpen()
If IsNull([Forms]![MyWorkspace]![EmailAttachment]) Then
CurrentAttach = ""
[Forms]![MyWorkspace]![EmailAttachment] = CurrentAttach & FileName
Else
CurrentAttach = [Forms]![MyWorkspace]![EmailAttachment] & "; " & FileName
MsgBox CurrentAttach
[Forms]![MyWorkspace]![EmailAttachment] = CurrentAttach
End If
[Forms]![MyWorkspace]![EmailAttachment].Locked = True
Else ' User chose No.
DoCmd.CancelEvent
exit_showSendDialog:
Exit Function
End If
err_showSendDialog:
If Err.Number = 2501 Then 'User Cancelled DoCmd
Resume exit_showSendDialog
Else 'Add your own error handling routine here
Resume exit_showSendDialog
Resume Next
End If
End Function
field of my form. This works fine if the field is null. However if the
field is already populated it will not let me add an additional file path for
an attachment. how can i modify this code so I can attach multiple files to
the field? Thanks
****************CODE****************
Function InsertNewFile()
Dim FileName As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to insert an attachment?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Warning" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
On Error GoTo err_showSendDialog
Dim CurrentAttach As String
If Response = vbYes Then ' User chose Yes.
'[Forms]![MyWorkspace]![LPID]
[Forms]![MyWorkspace]![EmailAttachment].Locked = False
FileName = FileToOpen()
If IsNull([Forms]![MyWorkspace]![EmailAttachment]) Then
CurrentAttach = ""
[Forms]![MyWorkspace]![EmailAttachment] = CurrentAttach & FileName
Else
CurrentAttach = [Forms]![MyWorkspace]![EmailAttachment] & "; " & FileName
MsgBox CurrentAttach
[Forms]![MyWorkspace]![EmailAttachment] = CurrentAttach
End If
[Forms]![MyWorkspace]![EmailAttachment].Locked = True
Else ' User chose No.
DoCmd.CancelEvent
exit_showSendDialog:
Exit Function
End If
err_showSendDialog:
If Err.Number = 2501 Then 'User Cancelled DoCmd
Resume exit_showSendDialog
Else 'Add your own error handling routine here
Resume exit_showSendDialog
Resume Next
End If
End Function