M
M.Jamal
Hello there!
I am using the following code succesfully to rename and move the selected
image file. ( Code courtesy of Mr. Douglas J. Steele in this group and i
modified it a litle bit.)
Private Sub Command12_Click()
Dim dbCurr As DAO.Database
Dim qdf As QueryDef
Dim rsCurr As DAO.Recordset
Dim strFolder As String
Dim strNewFile As String
Dim strOldFile As String
Dim strSQL As String
' Define what folder the pictures are in.
' Note that the final slash must be there
strFolder = "Z:\Products Database Photos\"
' Define the SQL to get the data from the table.
' (Change the field and table names as required)
strSQL = "SELECT [Products].Item No, [Products].tempfilelocation" & " " & _
"FROM [Products]" & " " & _
"WHERE (((Products.[Item No])=[Forms]![Add Product]![Item No]));"
Set dbCurr = CurrentDb()
Set qdf = dbCurr.QueryDefs("Query1")
qdf.Parameters("[Forms]![Add Product]![Item No]") = [Forms]![Add
Product]![Item No]
Set rsCurr = qdf.OpenRecordset
Do While rsCurr.EOF = False
strNewFile = strFolder & rsCurr![Item No] & ".jpg"
strOldFile = [tempfilelocation]
' Make sure that the file pointed to by ImageID exists,
' and that the desired renamed file doesn't exist.
' (You didn't say what you wanted done if the
' desired renamed file does exist!)
If (Len(Dir(strOldFile)) > 0) And (Len(Dir(strNewFile)) = 0) Then
Name strOldFile As strNewFile
End If
rsCurr.MoveNext
Loop
End Sub
In case when the desired rename image exists, i want to show up a windows
file overwrite confirmation box and ask for the user approval, if clicked
yes, the old file must be overwritten by the new file.
any ideas!!
Thanks in advance.
I am using the following code succesfully to rename and move the selected
image file. ( Code courtesy of Mr. Douglas J. Steele in this group and i
modified it a litle bit.)
Private Sub Command12_Click()
Dim dbCurr As DAO.Database
Dim qdf As QueryDef
Dim rsCurr As DAO.Recordset
Dim strFolder As String
Dim strNewFile As String
Dim strOldFile As String
Dim strSQL As String
' Define what folder the pictures are in.
' Note that the final slash must be there
strFolder = "Z:\Products Database Photos\"
' Define the SQL to get the data from the table.
' (Change the field and table names as required)
strSQL = "SELECT [Products].Item No, [Products].tempfilelocation" & " " & _
"FROM [Products]" & " " & _
"WHERE (((Products.[Item No])=[Forms]![Add Product]![Item No]));"
Set dbCurr = CurrentDb()
Set qdf = dbCurr.QueryDefs("Query1")
qdf.Parameters("[Forms]![Add Product]![Item No]") = [Forms]![Add
Product]![Item No]
Set rsCurr = qdf.OpenRecordset
Do While rsCurr.EOF = False
strNewFile = strFolder & rsCurr![Item No] & ".jpg"
strOldFile = [tempfilelocation]
' Make sure that the file pointed to by ImageID exists,
' and that the desired renamed file doesn't exist.
' (You didn't say what you wanted done if the
' desired renamed file does exist!)
If (Len(Dir(strOldFile)) > 0) And (Len(Dir(strNewFile)) = 0) Then
Name strOldFile As strNewFile
End If
rsCurr.MoveNext
Loop
End Sub
In case when the desired rename image exists, i want to show up a windows
file overwrite confirmation box and ask for the user approval, if clicked
yes, the old file must be overwritten by the new file.
any ideas!!
Thanks in advance.