Previous Thread

7/30/2006 3:13:14 AM    Where?...How? -- SHELL w/ DOS commands - Having a TOUGH Time....
I'm having a TOUGH time trying to get this going... 
 
And what makes it so aggravating is that I'm sure it's something simple..... 
 
I'm just not familiar enough with Access VBA, Modules, etc to do it. 
 
After  lots of reading on this board......it looks like the SHELL command is 
 
what's needed.....but I can't figure out exactly how to implement it so that 
 
it will execute when clicking a button on a form. 
 
I'm needing to copy all the files in a specfic directory  to another 
 
directory. 
 
All paths are static....the only variable will be the Name of the source 
 
directory.  The name of that given source directory is displayed in a text 
 
box on the form. 
 
This is the command that I think should do it: 
 
Shell ("xcopy c:\MainDirectory\"& [forms]![MyForm]![DirTextBox] & "\*.* /s /y 
 
C:\TargetDir") 
 
However....I don't know WHERE / HOW to put/create this command  (in a Macro... 
 
in a Module...other...?)  so that it can be activated by clicking a button on 
 
the form. 
 
I'm sure that must be really basic process...but I can't some to get things 
 
going. 
 
Any help appreciated. 
 
Thanks 
 
-- 
 
Message posted via AccessMonster.com 
 
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200607/1



7/30/2006 7:37:16 AM    Re: Where?...How? -- SHELL w/ DOS commands - Having a TOUGH Time....
You'd call that in a module. However, Shell is a function: you're supposed 
 
to have a variant variable to which you can assign its return value: 
 
Dim varReturn As Variant 
 
varReturn = Shell(...) 
 
or else call it: 
 
Call Shell(...) 
 
As well, if there's a chance that what's in DirTextBox can contain spaces, 
 
you'll need quotes around the folder details: 
 
Shell ("xcopy ""c:\MainDirectory\"& [forms]![MyForm]![DirTextBox] & "\*.*"" 
 
/s /y C:\TargetDir") 
 
In fact, since MainDirectory is more than 8 characters, you might want to do 
 
that even if DirTextBox will never contain spaces. 
 
-- 
 
Doug Steele, Microsoft Access MVP 
 
http://I.Am/DougSteele 
 
(no private e-mails, please) 
 
"kev100 via AccessMonster.com" <u16246@uwe> wrote in message 
 
news:640004cee6ee1@uwe...