Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup Code worked in XP, now not working in Win7

Status
Not open for further replies.

MaggieKCSR

Technical User
Dec 7, 2010
5
US
We have a data backup function attached to a button on our frontend. The back up function copies the open backend file to the root on the C: drive. This worked for years in XP. In Win7 this either gives an error "The expression On Click you entered as the event property setting produced the following error: Permission Denied". This error occurs or Access just locks up. Here is the code...I hope someone has an answer. :)

"
Public Sub BackUp()
'This function backs up to the C: drive, you can back up to any location, just change the strDest Value

On Error GoTo Err_Backup
Dim db As Database
Dim strSource As String, strDest As String, strError As String
Dim strDate As String, strDateX As String
Dim fso As FileSystemObject

If MsgBox("Would you like to back up your data to drive C:?", vbQuestion + vbYesNo, " Continue?") = vbYes Then
' Un-comment the following 3 lines for a new backup for every day
'strDate = Format(Date, "mm/dd/yy")
'strDateX = Left(strDate, 2) & Mid(strDate, 4, 2) & Right(strDate, 2)
'strDest = "a:\" & strDateX

Set db = CurrentDb()
DoCmd.Hourglass True

'Put any table name in here that exists in your back-end
strSource = db.TableDefs("QME/AME Information").Connect
strSource = Mid(strSource, 11, Len(strSource) - 10)

' If you are using a new back-up every day, un-comment this line and replace the database name, and comment out the next line down
'strDest = strDest & "_db1_be.accdb"

' Replace with your database Back-end name and different drive letter or UNC Path if desired
strDest = "C:\db1_be.accdb"

Set fso = New FileSystemObject
fso.copyfile strSource, strDest, True

db.Close
Set fso = Nothing

DoCmd.Hourglass False
MsgBox ("Backup Complete, Please Open Windows Explorer and Verify that the File db1_be.accdb was copied to your Back Up Destination")
End If

Exit_Backup:
Exit Sub

Err_Backup:
Select Case Err.number
Case 61
strError = "Disk is full" & vbNewLine & "cannot export accdb"
MsgBox strError, vbCritical, " Disk Full"
Kill strDest
Case 71
strError = "No disk in drive" & vbNewLine & "please insert disk"
MsgBox strError, vbCritical, " No Disk"
Case Else
Err.Raise Err.number, Err.Description
End Select

DoCmd.Hourglass False
Resume Exit_Backup

End Sub
 
Try putting it somewhere other than the root of your c: drive.

Let us know if you still get an error.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Yeah, I'm with traingamer for sure. It sounds to me like when you were upgraded to Win7, the IT admin folks placed write protection on the C drive.

Where I work, you can create subfolders on the C drive on some computers, and put files in that, but you can't just stick a file directly on the C drive.
 
I'm not sure that you need to blame the admin guys. I've not done anything to my Windows 7 machine but if I'm logged in as a regular user then it tells me I can't save anything in the root of c:.

Geoff Franklin
 
I have checked the user permissions on the local C drive. The User has Full Control and access to the C drive. This still didn't work. The code doesn't work and an hour glass icon shows up. I haven't tried changing the code to write to a directory yet.
 
You guys rock! I changed the code to write to a directory and it works again! Now the only problem is I have to issue an update to all our users with the change. Any idea why Win7 won't allow a write like this to the root?
 
alvechurchdata,

Not blaming anyone. Oftentimes, in corporate networks, things get caught and fixed (or updated to current policy) when systems are rebuilt, reordered, etc.
 
It's definitely a permissions issue. Previously, I was unable to create or write any files directly to my C drive at work, but now I am able to - they had to change various permissions to get a few certain things to work correctly. Or at least that was the easy way to fix them, I imagine there may have been a more difficult way otherwise.
 
In this case there is no IT. This is a stand alone program in Access which is distributed to individual end users. I was unable to get this code working even though I set Full Control to the C: drive on the development PC. I had to made the change in the code to write the backup to a directory or risk end users getting an error or lock up.
 
I just re-tested and my fix DID NOT work. Access in Win7 locks up when using the above code. It worked fine in XP...win7 it locks up. Any ideas?
 
One thing not mentioned so far, and maybe it could be it - UAC - is UAC (User Account Control) in Win7 enabled or disabled? Try with it disabled and see... I've had a couple/few installs of apps fail or have errors b/c of UAC in the past.
 
I have a strange issue: MsgBox itself does not work on Win7.
Do you see the message box ?

I have an application that works ok on XP, with all access or access runtime versions I could test, does not work on Win7.
I discovered that the problem is exactly with the Msgbox, it simply doesnt not popup

 
It's not a Win7 issue with MsgBox, b/c I've got Win7 and MsgBox works just fine. Sorry, it's something else... perhaps some sort of security settings by a 3rd party app?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top