|
-
Apr 11th, 2007, 07:23 PM
#1
Thread Starter
Addicted Member
compact mdb vb6
hi there,
do you have any sample code that will compact and repair mdb file 2002 thru vb6
thanks,
alexis
-
Apr 12th, 2007, 02:49 AM
#2
Lively Member
Re: compact mdb vb6
check this out..
I have found this piece of code in the code repository of this forum..
vb Code:
Option Explicit
Private Sub Command1_Click()
On Error GoTo MyError
Dim oApp As Access.Application
Set oApp = New Access.Application
oApp.DBEngine.CompactDatabase "D:\INVOICE.mdb", "D:\INVOICECpd.mdb"
Kill "D:\INVOICE.mdb"
Name "D:\INVOICECpd.mdb" As "D:\INVOICE.mdb"
MsgBox "Compact Complete!", vbOKOnly
oApp.Quit acQuitSaveNone
Set oApp = Nothing
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly
End Sub
-
Apr 12th, 2007, 02:58 AM
#3
Re: compact mdb vb6
 Originally Posted by alexis23
hi there,
do you have any sample code that will compact and repair mdb file 2002 thru vb6
thanks,
alexis
The only issue with the code posted above is that you need to have access installed on the system to compact / repair the mdb.
Take a look at this post.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Apr 12th, 2007, 03:01 AM
#4
Re: compact mdb vb6
Make sure you reference this in VB IDE.
Go To Project> Reference
Microsoft ActiveX Data Objects 2.x Library
Microsoft Jet and Replication Objects 2.x Library
-
Apr 12th, 2007, 03:24 AM
#5
Re: compact mdb vb6
You can also use the command line switche to run this out of sync.
Shell("PathToAccess\Access"" \Compact"" ""DatabaseFile"" ")
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Nov 21st, 2007, 01:16 AM
#6
Fanatic Member
Re: compact mdb vb6
Hi all
I tried this code and come with compile error:
user define type not define
Code:
Option Explicit
Private Sub Command1_Click()
On Error GoTo MyError
Dim oApp As Access.Application
Set oApp = New Access.Application
oApp.DBEngine.CompactDatabase "D:\INVOICE.mdb", "D:\INVOICECpd.mdb"
Kill "D:\INVOICE.mdb"
Name "D:\INVOICECpd.mdb" As "D:\INVOICE.mdb"
MsgBox "Compact Complete!", vbOKOnly
oApp.Quit acQuitSaveNone
Set oApp = Nothing
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly
End Sub
reference to this
Microsoft ActiveX Data Objects 2.x Library
Microsoft Jet and Replication Objects 2.x Library
I am using vb6 and access 2003
Thanks in advance
Regard,
Cesin
-
Nov 21st, 2007, 01:19 AM
#7
Lively Member
Re: compact mdb vb6
 Originally Posted by ksuwanto8ksd
reference to this
Microsoft ActiveX Data Objects 2.x Library
Microsoft Jet and Replication Objects 2.x Library
I am using vb6 and access 2003
Thanks in advance
Regard,
Cesin
 Originally Posted by zynder
Make sure you reference this in VB IDE.
Go To Project> Reference
Microsoft ActiveX Data Objects 2.x Library
Microsoft Jet and Replication Objects 2.x Library
You have to set the references to the lib files through your project->references view, as zynder explained earlier.
Please use the search function prior to posting a question and see if someone's already answered it.
-If I helped you, please rate me, as I'd do the same for you =)
-Remember to select the Resolved option for your post when you've gotten the answers you need.
-
Nov 21st, 2007, 04:56 AM
#8
Lively Member
Re: compact mdb vb6
NEATO is right.
you have to set the references first then try the code.
-
Nov 21st, 2007, 07:26 AM
#9
Re: compact mdb vb6
Moved to database development
-
Nov 21st, 2007, 08:11 AM
#10
Fanatic Member
Re: compact mdb vb6
when a DB is compacted is it also repaired??
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
|