PC Review


Reply
Thread Tools Rate Thread

Compact code not working-

 
 
Shane
Guest
Posts: n/a
 
      18th Sep 2003
Hi,
I saw the code postd that deleted tables if the admin
didnt open a form before a certain date.Ive been playing
around with it for about an hour and I cant seem to get
the Auto Compact to work. The code will run and quit, but
wont compact, Even if the compact on close option is
checked. Anyone know how to fix this?? Zach, did you
have the same problem???
Thanks

The code looks like this:

Private Sub Form_Open(cancel As Integer)
Dim db As DAO.Database, strUser As String
Dim dteDate As Date
Set db = CurrentDb
strUser = CurrentUser 'sees whose Logged On
If strUser <> "admin" Then 'if its NOT the admin
dteDate = DLookup("[Login]", "Log") 'look at the log
for the date
If DateDiff("d", dteDate, date) > 2 Then 'if that date is
older than 2 days, in this case
db.TableDefs.Delete "Table" 'delete table
db.QueryDefs.Delete "Query" 'delete query
DoCmd.DeleteObject acForm, "Form" 'delete form
DoCmd.DeleteObject acReport, "Report" 'delete report
DoCmd.DeleteObject acMacro, "Macro" 'delete macro
End If
ElseIf strUser = "admin" Then ' or if the user IS the
admin
db.Execute "UPDATE Log SET Log.[Login]= date();",
dbFailOnError 'update the field with todays date
Set db = Nothing
Application.SetOption "Auto Compact", True
Application.Quit
End If

End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compact pst not working! Crash Fistfight Microsoft Outlook Discussion 5 30th Nov 2010 01:23 PM
Compact Not working Mike T Windows Vista Mail 1 20th Feb 2007 03:56 PM
Compact now not working Jon Microsoft Outlook Discussion 3 30th Nov 2005 06:45 PM
Compact from code again VB Microsoft Access Form Coding 0 26th Aug 2004 08:52 AM
Re: Compact From Code Jim Allensworth Microsoft Access Form Coding 1 24th Aug 2004 09:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:03 AM.