|
-
Sep 19th, 2000, 03:05 AM
#1
Hallo
I want to activate the rebuilding and compacting of my database after a certain period elapsed. The problem starts with the Compact-method. I have to specify a new db name (the compacted one), therefore I have to delete the old one, rename the new one so that it has the same name as the old db. For some reason the DELETE (of file) and RENAME methods are not accepted at Design-time. Is there some other way of doing this?
I need help!
Thank you
-
Sep 19th, 2000, 04:00 AM
#2
Frenzied Member
shouldn't be a problem
Are you closing the database before trying to delete it?
-
Sep 19th, 2000, 04:10 AM
#3
When I compile/Run code, the methods are not recognized by VB. So I did not even get to the point where I might get an error that database is open. Do you maybe know why?
Thanx
-
Sep 19th, 2000, 04:15 AM
#4
Frenzied Member
Lets have a look at your code
-
Sep 19th, 2000, 06:01 AM
#5
Try something like the following:
Code:
Private Sub CompactTheDB()
Dim strOldDBName As String
Dim strNewDBName As String
strOldDBName = "C:\Whatever\TheDBName.mdb"
strNewDBName = "C:\Whatever\TheDBName.bkp"
DBEngine.CompactDatabase strOldDBName, strNewDBName
Kill strOldDBName
Name strNewDBName As strOldDBName
End Sub
"It's cold gin time again ..."
Check out my website here.
-
Sep 19th, 2000, 08:06 AM
#6
Junior Member
Hi Guys
First, i should explain i am new to VB programming although i have been building Access97 apps. for about two years now.
I have a module in an otherwise empty database that compacts and backs up another database everynight which is the one all the guys in my office log into each day.
I'd like to build it in VB, and i'm doing ok in terms of the databse name, location etc, but here is my problem:
Would i have to open some instance of Access to use DBEngine.CompactDatabase, or will it run from within VB as it is?
Sorry if this is a basic question, but we all have to start somewhere.....
I only ask as i have to do a similar thing when creating Word docs. for mail merge from within Access.
Cheers
Peter Gidden
-
Sep 19th, 2000, 08:18 AM
#7
Note: The info below assumes that DAO is being used.
PeterGUK:
The answer to your question is no, you do not have to open an instance of Access to compact the DB from VB. In your VB project, go to the Project menu, then References, and check "Microsoft DAO 3.6 Object Library" (or DAO 3.51, or whatever latest version shows up there). Once this reference is set, you can access any object of the DBEngine. Thus, the code I posted earlier should work for you.
hermanvd:
I got your e-mail regarding your use of the ADODC, which I'm sorry to say I have not used, except for once doing a tutorial. I'm afraid I can't help you with that one.
"It's cold gin time again ..."
Check out my website here.
-
Sep 19th, 2000, 08:44 AM
#8
Junior Member
Thanks Bruce, i'm off to give it a go.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|