Solved

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

Posted on 2011-02-23
7
238 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 500 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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now