CeCopyFile - VB in MS Access



Firstly, sorry if this is in the wrong area, but this seemed to be the more
active area.

I have searched everywhere, both here and via google for an answer on how to
use the CeCopyFile function in VB but I can not find the answer I am looking
for.

I have an Access database I use to push and pull files to and from the PDA to
a network server using the functions as provided by Microsoft that everyone
seems to use. This works fantastic as I use a table to define the files and
paths to complete the transfer of the data to and from.

I was asked the other day if I could backup the files on the PDA to itself
prior to a transfer of the files from the PDA to the network as a means of
safe guarding the data a little more. After a quick google search it appears
the CeCopyFile is the way to go and I realise that this only copies files
from one location on the PDA to another, which is exactly what i want.

The problem is that i do not know how to implement the code in Access to get
it to work!

I have the following code at the moment

<CODE>
Public Declare Function CeCopyFile Lib "rapi.dll" ( _
ByVal CurrentPath As String, _
ByVal NewPath As String, _
ByVal Overwrite As Boolean) As Long
</CODE>

I use this funtion in a custom function to pass the variables

<CODE>
Public Function buFiles(sOLoc As String, sDLoc As String, bFailIfExists As
Boolean)

'bFailIfExists = True if you DO NOT want to overwrite!

If Not RapiIsConnected Then
MsgBox "Device is not connected. Please connect first."
Exit Function
End If

'Do the file copy
Dim lBU As Long

lBU = CeCopyFile(sOLoc, sDLoc, bFailIfExists)

'Check CeGetLastError
Dim lLastError As Long
If lBU = False Then
lLastError = CeGetLastError()
End If

Select Case lLastError
Case ERROR_FILE_EXISTS
MsgBox "A file already exists with the specified name."
Case ERROR_INVALID_PARAMETER
MsgBox "A parameter was invalid."
Case ERROR_DISK_FULL
MsgBox "Disk if Full."
Case 32
MsgBox "File access error. It is possible that Arcpad in your
mobile device is still running." & vbCrLf & "Please close the Arcpad in the
mobile device and try again."
Case Else
MsgBox "An unknown error occured."
End Select

End Function
</CODE>

When I run this function ( ?buFiles("\Temp\CannedText.txt", "\Temp\BU\
CannedText.txt", False) ) in the Immediate Window (Ctrl + G) it gives me an
error message where the error number is '2' which when looking at the RAPI
documentation relates to a "Can not find file location" error.

Can someone please point me in the right direction as to why it can not find
the location on the PDA or where else I might not be calling the function
correctly.

Cheers

Dave - inf3rno

.



Relevant Pages

  • Macro problem.
    ... >I get the following msgbox when I attempt to run a Macro - ... >simple text string to be put into a cell. ... >Tried a google no help.. ...
    (microsoft.public.excel.misc)
  • Re: Change Address Fields with Combo on Form
    ... MsgBox "Update Completed" ... Private Sub cmb_Addr_change_AfterUpdate ... Dim SQL_Text As String ... MsgBox "Update canceled by user" ' Cancel update. ...
    (microsoft.public.access.forms)
  • Re: Macro Debugging - I cant figure out whats wrong!
    ... string stored in the array. ... This is easier than writing MsgBox or Debug.Print ... Dim i As Long, prange As String, srange As Range ... Dim strNum As String ...
    (microsoft.public.word.vba.general)
  • Re: Problem converting string to number: "Type mismatch" error
    ... try this Msgbox lname after you get the value from the registry. ... Dim CollectData As String ...
    (microsoft.public.vb.general.discussion)
  • Re: ADP bound form - force record save, recordsetclone not populating after requery
    ... Function RefreshForm(myForm As Form, myField As String) ... Dim rs As ADODB.Recordset ... MsgBox "YOU HAVE NOT MADE A SELECTION" ... recordsetclone on ADO form recordsets in the 2000 version - could you try just using the ..clone method of the form recordset in stead, and see if that changes anything? ...
    (comp.databases.ms-access)