Private Sub Command231_Click()
'Add attachments to Change Request
On Error GoTo ErrorHandler
Dim strFilter As String
Dim strInputFileName As String
Dim strSQL As String
'Check to see if any more attachments can be added
If Len(Nz(Me.Attachment1, "")) <> 0 Then
If Len(Nz(Me.Attachment2, "")) <> 0 Then
If Len(Nz(Me.Attachment3, "")) <> 0 Then
MsgBox "You cannot add any more attachments"
Exit Sub
End If
End If
End If
'Add attachment to first available field
'Take copy of file to be attached and
'place copy in directory on K:\ drive
'Place hyperlink to file on K:\ drive
'in appropriate attachment field
strFilter = ahtAddFilterItem(strFilter, _
"All Files (*.*)", _
"*.*")
strInputFileName = ahtCommonFileOpenSave(Filter:=strFilter, _
OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
If Len(Nz(Me.Attachment1, "")) = 0 Then
Me.Attachment1 = strInputFileName
Dim origpath, newpath As String
Me.Attachment1.SetFocus
origpath = Me.Attachment1.Text
newpath = "K:\Rapid\BST - general\Release Testing\Change Request Log\Attachments\" & "CR" & (Me.Abbreviation) & Format(Me.RequestID, "00000") & "Att1" & Right(Me.Attachment1, 4)
FileCopy origpath, newpath
Me.Attachment1 = newpath
ElseIf Len(Nz(Me.Attachment2, "")) = 0 Then
Me.Attachment2 = strInputFileName
Me.Attachment2.SetFocus
origpath = Me.Attachment2.Text
newpath = "K:\Rapid\BST - general\Release Testing\Change Request Log\Attachments\" & "CR" & (Me.Abbreviation) & Format(Me.RequestID, "00000") & "Att2" & Right(Me.Attachment2, 4)
FileCopy origpath, newpath
Me.Attachment2 = newpath
ElseIf Len(Nz(Me.Attachment3, "")) = 0 Then
Me.Attachment3 = strInputFileName
Me.Attachment3.SetFocus
origpath = Me.Attachment3.Text
newpath = "K:\Rapid\BST - general\Release Testing\Change Request Log\Attachments\" & "CR" & (Me.Abbreviation) & Format(Me.RequestID, "00000") & "Att3" & Right(Me.Attachment3, 4)
FileCopy origpath, newpath
Me.Attachment3 = newpath
End If
'Message to user if they cancel the operation
ErrorHandler:
If Err = 75 Then
MsgBox "You have not selected a file to attach to this Change Request"
ElseIf Err = 76 Then
MsgBox "You have not selected a file to attach to this Change Request"
End If
End Sub