Here is the code it works just fine for copying and moving stuff into the database folder that contains all the images etc which are referenced in a SQL table. The error occurs when the user wants to MOVE a file to the database folder and that file already exsists in the folder. I Get an error '58' file already exsists. What I want to do is have a msg box stating that ( I have no problem with doing the msgbox)and the user click the ok in the msg box and be returned to the form so he can then move on to correcting the situation without exiting the app.
Any help would be appreciated
Thanks
Private Sub Command1_Click()
If Check4.Value = False And Check5.Value = False And Check6.Value = False Then
iReturnValue = MsgBox("C or S1 or S2 must be selected", vbOKOnly)
Else
Dim strFilename
Dim strPath
Dim i
Dim strSourceFileName
Dim strDestinationFileName
For i = 1 To frmImages.File1.ListCount
strFilename = (frmImages.File1.FileName)
strPath = (frmImages.File1.Path)
Next
Set fs = CreateObject("Scripting.FileSystemObject"
If chkKeep = 1 Then
fs.CopyFile Text1.Text, "c:\rp\"
ElseIf chkKeep = 0 Then
fs.MoveFile Text1.Text, "c:\rp\"
File1.Refresh
Set fs = Nothing
End If
Dim objConn
Set objConn = New ADODB.Connection
objConn.ConnectionString = "DSN=eDoan;UID=sa"
objConn.Open
Dim objRS
Set objRS = objConn.Execute("Select * from tblImages"
Dim strSQL
If objRS.RecordCount <> 0 Then
ClaimID = (frmImages.txtClaimNumber.Text)
End If
strPath2 = ("C:\rp\"
strSQL = "insert into tblImages (ClaimID, Description, Checked, CheckedS1, CheckedS2) values ('" & frmImages.txtClaimNumber.Text & "','" & strPath2 & strFilename & "','" & Check4.Value & "','" & Check5.Value & "','" & Check6.Value & "')"
objConn.Execute (strSQL)
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
iReturnValue = MsgBox("Image has been saved", vbOKOnly)
End If
End Sub
========
This is the area of concern
----------
Set fs = CreateObject("Scripting.FileSystemObject"
If chkKeep = 1 Then
fs.CopyFile Text1.Text, "c:\rp\"
ElseIf chkKeep = 0 Then
fs.MoveFile Text1.Text, "c:\rp\"
File1.Refresh
Set fs = Nothing
End If
Any help would be appreciated
Thanks
Private Sub Command1_Click()
If Check4.Value = False And Check5.Value = False And Check6.Value = False Then
iReturnValue = MsgBox("C or S1 or S2 must be selected", vbOKOnly)
Else
Dim strFilename
Dim strPath
Dim i
Dim strSourceFileName
Dim strDestinationFileName
For i = 1 To frmImages.File1.ListCount
strFilename = (frmImages.File1.FileName)
strPath = (frmImages.File1.Path)
Next
Set fs = CreateObject("Scripting.FileSystemObject"
If chkKeep = 1 Then
fs.CopyFile Text1.Text, "c:\rp\"
ElseIf chkKeep = 0 Then
fs.MoveFile Text1.Text, "c:\rp\"
File1.Refresh
Set fs = Nothing
End If
Dim objConn
Set objConn = New ADODB.Connection
objConn.ConnectionString = "DSN=eDoan;UID=sa"
objConn.Open
Dim objRS
Set objRS = objConn.Execute("Select * from tblImages"
Dim strSQL
If objRS.RecordCount <> 0 Then
ClaimID = (frmImages.txtClaimNumber.Text)
End If
strPath2 = ("C:\rp\"
strSQL = "insert into tblImages (ClaimID, Description, Checked, CheckedS1, CheckedS2) values ('" & frmImages.txtClaimNumber.Text & "','" & strPath2 & strFilename & "','" & Check4.Value & "','" & Check5.Value & "','" & Check6.Value & "')"
objConn.Execute (strSQL)
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
iReturnValue = MsgBox("Image has been saved", vbOKOnly)
End If
End Sub
========
This is the area of concern
----------
Set fs = CreateObject("Scripting.FileSystemObject"
If chkKeep = 1 Then
fs.CopyFile Text1.Text, "c:\rp\"
ElseIf chkKeep = 0 Then
fs.MoveFile Text1.Text, "c:\rp\"
File1.Refresh
Set fs = Nothing
End If