Log in

View Full Version : You do not have the necessary permissions



austenr
11-15-2006, 07:37 AM
I have a corrupted database I think. I have read the Microsoft KB about this error but it is more confusing than helpful. This appeared after the following scenario occurred:

I attempted to open the DB but I got an error saying that someone else was trying to use the DB at the same time I was. This DB is not shared with anyone. I then tried the Microsoft suggestion on doing a repair. The repair abended with out completing with the message in the subject line.

Does anyone know a way around this so i can access the tables and queries? It would be a lot of work to rebuild all of what is potentially lost. Thanks :banghead:

OBP
11-15-2006, 09:33 AM
What no Backup?
You could try creating a blank database and then "Importing" everything from the original, sometimes it fools Access and lets you.
Have you switched off your Computer and tried opening it again?
Take a copy and try and open that instead.

austenr
11-15-2006, 09:38 AM
Nope no back up. I learned my lesson on that. :doh: I tried your suggestions yesterday with no luck. So I guess its toast. Now back to the business of recreating the queries. This time I have multiple backups.

OBP
11-15-2006, 09:43 AM
I Compact & Repair after every major design change and Increment the version number in the database name each time. It is good practice because at most you only lose the last change.

austenr
11-15-2006, 12:04 PM
Well I guess this part is solved because I managed to re create my queries. Now, does anyone have any ideas on how I can back up my DB's at a certain time each day?

Imdabaum
11-15-2006, 01:17 PM
I have code that compacts and repairs every 4 months. But in order for it to back up you have to have the system open. I imagine if we changed the calculation to days instead of Months you would be able to do the same operation. I'm not sure how about the back up functionality, but here is something to start with. I do this code in a splash screen window that opens everytime a user opens the database. I also created one table with one entry the date of the last compact, or in this case the last backup. tblMaintenance: Field1: id=1 & Field2: Date= dteLastBackup.

This date is linked to an invisible field named dteBackup on the splash screen. Here's some talk through to start out with if you need any more help with it. I'll see what I can come up with or possibly others have a better way to handle it.


'**Splashload event
Public Sub Form_Load()
MaintenanceCheck()
End Sub

Private Function MaintenanceCheck()

On Local Error GoTo MCError1

Dim stDatabaseName as String
Dim stLastBackup as String
Dim stMessage as String
Dim stSQL as String
Dim intDateDiff as Integer 'How much time between backups?
Dim stToday as String

stToday = CStr(Date)
stLastCompacted = Me.LastBackupdate
''if it is on a network get the header info \\mynetworkplace\project\etc (file://\\mynetworkplace\project\etc)
stDatabaseName = Left(CurrentDb.Name, [length of header info without file name])
intDateDiff = DateDiff("d", stLastBackup, stToday)
If intDateDiff > week (or 7) Then
If MsgBox ("Make a backup of your database?, vbYesNo, "Maintenance") = vbYes Then
If BackupDB(stDatabaseName & "fileName.mdb", stDatabaseName & "fileNameBackup.mdb") Then

stSQL = "Update tblMaintenance SET Date = #" & stToday & "# Where ((tblMaintenance.id = 1))"
DoCmd.RunSQL stSQL

Else
MsgBox "Could not backup system. Get help"
End If
Else
MsgBox "User canceled backup request.", vbokayonly, "Message"
End if
End if

DoCmd.Close acForm, "frmSplash"
MCEnd:
Exit Function
MCError1:
MsgBox Err.number & Err.description
Resume MCEnd
End Function

Function BackupDB(strSource as String, strDestination as String) as Boolean

On Error GoTo error_Repair

RepairDB = Application.CompactRepair(strSource, strDestination)
Kill strSource
Name strDestination as StrSource

'*********
'to get the copy for backup
'There might be an easier way this is just quick coding
'*********
Copy(strSource, strDestination)


'********************
' Any needed error checking here.
' I'll see if there is an easier way to code the backup but this is a way to automate it.
'*************************************

austenr
11-15-2006, 01:20 PM
Thanks. Could you post a sample of the splash screen?

Imdabaum
01-17-2007, 11:58 AM
Sorry I didn't see this post earlier. A splash screen is nothing more than a form that may or may not appear. Typically it opens on startup and introduces the application with version number and maybe messages for users who access the database.


4786

mdmackillop
01-17-2007, 12:17 PM
Hi Austen,
Personally, I keep all the data in a separate file and use a Front End with links to the data. I have spare copies of this front end on my PC and on the server. I use a routine similar to the following to back up the data on a daily basis. If some corruption should occur, I at least have the previous data up to 5 days
Option Compare Database

Private Sub Command0_Click()
On Error Goto Err_Command0_Click

Backsup
DoCmd.Quit

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

Sub Backsup()
Dim SourceFile, DestinationFile
SourceFile = "C:\Data\MyData.mdb" ' Define source file name.
' Define target file name.
DestinationFile = "C:\Data\" & Format(Now(), "dddd") & "\MyData.mdb"
FileCopy SourceFile, DestinationFile ' Copy source to target.
End Sub

wiz47
01-24-2007, 06:04 PM
I have this sub execute on the exit command in my DB's. If the Frontend (in my case) is more than 5 megabytes, then the system will automatically perform a compact. It also does an fcopy of the be and serves as an automatic backup each time I close.


Private Sub CmdBackUp_Click()
On Error GoTo Err_CopyOnClose
fCopyFile "Sourcepath_to_the_be", "DestinationPath_to_where _I_want_the_backup_Stored"
If FileLen(CurrentDb.Name) > 500000 Then
Application.SetOption ("Auto Compact"), 1
Application.SetOption "Show Status Bar", True
vStatusBar = SysCmd(acSysCmdSetStatus, "The application must do some Routine
maintenance - Do NOT Press any Key until it completes!")
Else
Application.SetOption ("Auto Compact"), 0
End If

DoCmd.Quit

Exit_CopyOnClose:
Exit Sub
Err_CopyOnClose:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_CopyOnClose
End Sub

wiz47
01-24-2007, 06:16 PM
Hi Austen,
Personally, I keep all the data in a separate file and use a Front End with links to the data.

I have split all of my DB's now for that very reason. Even the ones that aren't on a network for multiusers. If I corrupt the fe (so what). :thumb

Carl A
01-27-2007, 01:04 PM
Here is a microsoft link for a download of a stand alone compact utility. This one is for 2000 but there is a link for a 2002 utility on the page. Microsoft claims that this utility may work where the built in compact and repair does not.
http://support.microsoft.com/kb/273956/EN-US/