Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21263

[RESOLVED] Copying My Database File

$
0
0
Thought I had this one licked.....

The following works 'sometimes' -- I HATE 'sometimes'. When I first start my program, I can select my menu option and export this .mdb file.
If I 'play around with' the program (where the db is used to update controls) and then try the menu option to export it, I get that Permissions Error again, but only SOMETIMES.
I have closed the connection, and closed the recordset. What else do I have to do to allow me to ALWAYS copy this file. (It is NOT open in another computer window this time.) I don't use 'lock' on my database at all, as there is only one user at a time.

Code:

Private Sub exportDatabase_Click()
If cnn.State = adStateOpen Then
  cnn.Close
  Set cnn = Nothing
End If
Dim State As Long
State = rs.State
If State <> 0 Then
rs.Close
Set rs = Nothing
End If
FileCopy App.Path & "\churchmembers.mdb", "c:\users\" & gUserName & "\desktop\churchmembers" & Format(Date, "YYYYMMDD") & ".mdb"
MsgBox "A file named 'churchmembers" & Format(Date, "YYYYMMDD") & ".mdb' has been placed on your desktop."
End Sub

the global variable gUserName is not an issue...as I stated above, it DOES work sometimes. And sometimes repeatedly (two or three time), but then, it fails and tells me I can't copy because I don't have permissions. (I am doing this on a standalone Win7 desktop.)

Viewing all articles
Browse latest Browse all 21263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>