Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Use Access 2010 macro and VBA code XCopy Folders and Files from network server to Tablet.

Posted on 2011-10-05
11
Medium Priority
?
781 Views
Last Modified: 2012-05-12
I need create an Access Macro that will copy folders and files from a server to a directory on tablet attached to the local workstation.  \\oiclx\public\tabletsync e:\.   I can either execute this from a macro, use vba from command button, run a batch file--which ever is best and least complicated but reliable.  Thank you.
0
Comment
Question by:MarkSnark1
  • 6
  • 5
11 Comments
 
LVL 16

Expert Comment

by:kmslogic
ID: 36921776
Something like this should work in a button click event to copy your files (in VBA):


    Dim strFile As String
   
    strFile = Dir("\\oiclx\public\tabletsync\*.*")
    While strFile <> ""
        FileCopy strFile, "E:\"
        strFile = Dir()
    Wend
0
 

Author Comment

by:MarkSnark1
ID: 36924720
I made the button as Kmslogic prescribed below but nothing happens when the button is pushed, no error message, no trouble shooter, nothing.  I appreciate your help.  While this looks like something that will work well for my purposeses it must need another tweak.

Private Sub Sync_Click()
  Dim strFile As String
   
    strFile = Dir("\\oiclx\public\tabletsync\*.*")
    While strFile <> ""
        FileCopy strFile, "E:\"
        strFile = Dir()
    Wend
 
End Sub


0
 
LVL 16

Expert Comment

by:kmslogic
ID: 36925286
Put a breakpoint (place your cursor on the strFile=Dir line and press the F9 function key) in the VB editor and then click the button.   Make sure we're getting into the function.  If we are then you can step through each line by pressing SHIFT-F8.  
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:MarkSnark1
ID: 36931127
Thank you for responding.  I put a bread point in where you said, saved the form, tried it again and still nothing happens.
0
 
LVL 16

Expert Comment

by:kmslogic
ID: 36931528
Ok if nothing happens then that function isn't set as your click event on the button.  Right click on the button and select properties so the properties box appears.  Click on the events tab.  Press the "..." button next to the event and select "Code Builder" and click Ok.  Put your code in the function it gives you.
0
 

Author Comment

by:MarkSnark1
ID: 36931756
Yes, That is what I showed you above after you gave the original code. Is there a way to check if "Filecopy" is a valid command on my system?  I am using Office/Access 2010.
0
 
LVL 16

Accepted Solution

by:
kmslogic earned 1000 total points
ID: 36932182
It is a valid command in Access 2010

If your event is set up correctly it should take you to the breakpoint you set when you click the button.  If it doesn't then your event isn't set up correctly.
0
 

Author Closing Comment

by:MarkSnark1
ID: 36932463
I was told that the event was not set up correctly but I set it up three different times to put the code in the Click event on the button and the code just is not running.  I showed the resulting setup from the vba editor.  I don't know what else to do.
0
 
LVL 16

Expert Comment

by:kmslogic
ID: 36932527
I understand your frustration, but really you shouldn't accept the answer if it doesn't solve your problem. If the on click event is set up correctly then you aren't setting up the breakpoint correctly.  I really has to be one of those two things.  When you press F9 on the line:

strFile = Dir("\\oiclx\public\tabletsync\*.*")

it should be highlighted in a dark red color which signifies the breakpoint is in place.  Then when you press the button on your form it should stop at this line of code.
0
 
LVL 16

Expert Comment

by:kmslogic
ID: 36932570
A couple of changes to what I sent you (of course you would have gotten an error message--not just "nothing"):


    strFile = Dir("\\oiclx\public\tabletsync\*.*")
    While strFile <> ""
        FileCopy "\\oiclx\public\tabletsync\" & strFile, "E:\" & strFile
        strFile = Dir()
    Wend

I typed that function from memory and it turns out strFile will just be the filename without the path hence the changes on the FileCopy line.

You're having another problem of getting the event to fire but I have tested the above code in Access 2010 and it does work.
0
 

Author Comment

by:MarkSnark1
ID: 36932845
Thanks for trying. I cannot think of what might be wrong.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

572 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