?
Solved

MS ACCESSS select all the jpg files and then copy and paste

Posted on 2011-02-23
7
Medium Priority
?
294 Views
Last Modified: 2012-05-11
Good morning,
I work in acces 2007 i have one form and i have make one Botton , then i want to select all the jpg files from one folder and copy with the same name to anather folder.
Thks For your help
0
Comment
Question by:ELPANOS
  • 4
  • 3
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34959522
Sub fc()
Dim SourceFile, DestinationFile
SourceFile = "C:\oldfolder\*.jpg"    ' Define source folder and files.
DestinationFile = "C:\newfolder\"    ' Define target folder.
 
Shell "cmd /C copy " & SourceFile & " " & DestinationFile & " "


End Sub
0
 

Author Comment

by:ELPANOS
ID: 34959614
Thks for your answer,
i have make the code but nothing is hapen

Private Sub TRANSFERFOTO_Click()
Dim SourceFile, DestinationFile
SourceFile = "\\Panorama-server\data (f)\PHOTOS\Update catalog êùäéêïðïéçóç\*.jpg"    ' Define source folder and files.
DestinationFile = "D:\FOTOCODE\"    ' Define target folder.
 
Shell "cmd /C copy " & SourceFile & " " & DestinationFile & " "
End Sub

Private Sub TRANSFERFOTO_Click()
Dim SourceFile, DestinationFile
SourceFile = "\\Panorama-server\data (f)\PHOTOS\Update catalog êùäéêïðïéçóç\*.jpg"    ' Define source folder and files.
DestinationFile = "D:\FOTOCODE\"    ' Define target folder.
 
Shell "cmd /C copy " & SourceFile & " " & DestinationFile & " "
End Sub

Open in new window

0
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 34959849
Set a breakpoint at line4 (destinationfile=...) and run the code.
When the code stops, click into the immediate window and  type..
?dir(sourcefile)

If the path is correct then you will see the name of the first file.
Otherwise you will just get a blank line.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ELPANOS
ID: 34959961
Thks For your help i find finalist this code and is worck, i give you for referance

Private Sub transferfoto_Click()
Dim fso
Dim sfol As String, dfol As String
sfol = "\\Panorama-server\data (f)\PHOTOS\Update catalog" ' change to match the source folder path
dfol = "D:\FOTOCODE" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If Not fso.FolderExists(sfol) Then
    MsgBox sfol & " is not a valid folder/path.", vbInformation, "Invalid Source"
ElseIf Not fso.FolderExists(dfol) Then
    MsgBox dfol & " is not a valid folder/path.", vbInformation, "Invalid Destination"
Else
    
    fso.CopyFile (sfol & "\*.*"), dfol ' Change "\*.*" to "\*.xls" to move Excel Files only
End If
If Err.Number = 53 Then MsgBox "File not found"
End Sub

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
ID: 34959998
The source path in your 'working' code is not the same as the source path you used in the 'not-working' code you posted earlkier.

0
 

Author Comment

by:ELPANOS
ID: 34960034
Peter i need also progressBar the time is transfer the fotos you can help me?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34960874
please post a new question so that more people see it.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question