To all,
Best regards.I have a problem.If anyone has any solution,please reply as soon as possible.
Is aouto purging possible in Access? How can I get related codes?
Zerin
13 3535 MMcCarthy 14,534
Recognized Expert Moderator MVP
To all,
Best regards.I have a problem.If anyone has any solution,please reply as soon as possible.
Is aouto purging possible in Access? How can I get related codes?
Zerin
Hi Zerin,
What are you trying to purge?
Mary
NeoPa 32,556
Recognized Expert Moderator MVP
If you are trying to purge unused data from your database this function should work for you. - 'CompactDb compacts a remote Access database.
-
Public Function CompactDb(ByVal strDB As String, _
-
Optional strPW As String = "") As Boolean
-
Dim strNewDB As String, strLocale As String
-
-
On Error GoTo ErrorCDB
-
strNewDB = Replace(strDB, ".Mdb", "New.Mdb")
-
Call Echo(True, "Compacting """ & strDB & """.")
-
If strPW <> "" Then strLocale = ";pwd=" & strPW
-
If Exist(strNewDB) Then Kill strNewDB
-
Call DBEngine.CompactDatabase(SrcName:=strDB, _
-
DstName:=strNewDB, _
-
DstLocale:=strLocale, _
-
SrcLocale:=strLocale)
-
Kill strDB
-
Name strNewDB As strDB
-
Call Echo(True, """" & strDB & """ compacted.")
-
CompactDb = True
-
Exit Function
-
-
ErrorCDB:
-
CompactDb = False
-
End Function
If not, then please explain your question more clearly so we can help you.
Thanks for your reply,
Actually,I developed a software using Visual Studio 2005 (by VB code).It uses Access database.Now,I want to delete data automatically after a month or two or any option given by the operator.
Can it be done? Please help me. Thanks in advance.
Zerin
MMcCarthy 14,534
Recognized Expert Moderator MVP
Thanks for your reply,
Actually,I developed a software using Visual Studio 2005 (by VB code).It uses Access database.Now,I want to delete data automatically after a month or two or any option given by the operator.
Can it be done? Please help me. Thanks in advance.
Zerin
Zerin where are the option selections being stored. If they are in a table on their own then. -
Dim strSQL As String
-
-
strSQL = "DELETE * FROM TableName;"
-
DoCmd.RunSQL
-
-
should do the job.
Mary
Dear mmccarthy ,
Thanks for your reply.Actually,I don't have any idea where to set the options. As far as I can understand,the delete method should find out the old data first and then delete them.Now, my software's requirement is that..............
1. The default value will be 1 month ( that means,identify first the old data and then delete every month's last day)
2. User choice should be given to select autopurging policy:
a) related to time ( Drop down list for selecting month)
b) related to disk space ( free 50% memory space or more)
The problem is,I can't understand where to add the modules...................in the database (Access 2003) or in the front end view (Visual Basic 2005 ) ? Actually,I don't know from where to start.
The database is working well.Only auto purging feature has to be added. Please help me.
Thanks in advance.
Zerin
Dear NeoPa ,
Thanks for your reply.Actually,I don't have any idea where to set the options will be better. As far as I can understand,the delete method should find out the old data first and then delete them.Now, my software's requirement is that..............
1. The default value will be 1 month ( that means,identify first the old data and then delete every month's last day)
2. User choice should be given to select autopurging policy:
a) related to time ( Drop down list for selecting month)
b) related to disk space ( free 50% memory space or more)
The problem is,I can't understand where to add the modules...................in the database (Access 2003) or in the front end view ( Visual Basic 2005 of Visual Studio 2005 ) ? Actually,I don't know from where to start.
The database is working well.Only auto purging feature has to be added. I tried your code but may be the version is different.Please help me.
Thanks in advance.
Zerin
Dear Neopa,
I tried the code in module with my Access database but it gives compilation error like: "Sub or Function not defined " for the following line of code:
If Exist(strNewDB) Then Kill strNewDB
the full code you sent me was:
Public Function CompactDb(ByVal strDB As String, _
Optional strPW As String = "") As Boolean
Dim strNewDB As String, strLocale As String
On Error GoTo ErrorCDB
strNewDB = Replace(strDB, ".Mdb", "New.Mdb")
Call Echo(True, "Compacting """ & strDB & """.")
If strPW <> "" Then strLocale = ";pwd=" & strPW
If Exist(strNewDB) Then Kill strNewDB
Call DBEngine.CompactDatabase(SrcName:=strDB, _
DstName:=strNewDB, _
DstLocale:=strLocale, _
SrcLocale:=strLocale)
Kill strDB
Name strNewDB As strDB
Call Echo(True, """" & strDB & """ compacted.")
CompactDb = True
Exit Function
ErrorCDB:
CompactDb = False
End Function
Zerin
Personally, I think I would do the work in the VB program, but create a new table in the database to store the selected option(s).
The purge could be set up to happen when someone starts or leaves the program, or whatever you prefer.
As for NeoPa's suggestion, it may be a good one but I don't think it's relevant in this case. It is for "compacting" the database, which basially just reclaims the space taken up by records which have been deleted (wasted space). It has nothing to do with the actual deleting.
MMcCarthy 14,534
Recognized Expert Moderator MVP
Dear mmccarthy ,
Thanks for your reply.Actually,I don't have any idea where to set the options. As far as I can understand,the delete method should find out the old data first and then delete them.Now, my software's requirement is that..............
1. The default value will be 1 month ( that means,identify first the old data and then delete every month's last day)
2. User choice should be given to select autopurging policy:
a) related to time ( Drop down list for selecting month)
b) related to disk space ( free 50% memory space or more)
The problem is,I can't understand where to add the modules...................in the database (Access 2003) or in the front end view (Visual Basic 2005 ) ? Actually,I don't know from where to start.
The database is working well.Only auto purging feature has to be added. Please help me.
Thanks in advance.
Zerin
Zerin if this was all being done in Access the function would go in a module and be called in an event on the form. I'm really sorry but I don't know how to do this in Visual Basic.
Mary
MMcCarthy 14,534
Recognized Expert Moderator MVP
Zerin if this was all being done in Access the function would go in a module and be called in an event on the form. I'm really sorry but I don't know how to do this in Visual Basic.
Mary
Zerin
I'm going to ask someone else to take a look at this so don't give up yet.
Mary
NeoPa 32,556
Recognized Expert Moderator MVP
Personally, I think I would do the work in the VB program, but create a new table in the database to store the selected option(s).
The purge could be set up to happen when someone starts or leaves the program, or whatever you prefer.
As for NeoPa's suggestion, it may be a good one but I don't think it's relevant in this case. It is for "compacting" the database, which basially just reclaims the space taken up by records which have been deleted (wasted space). It has nothing to do with the actual deleting.
What you say is absolutely true, except that I was replying to the original post and it's certainly not clear from that that record deletions are required rather than a Compact/Repair.
If they are of course, then the DELETE SQL posted by Mary should do. I suspect that the best idea is to put whatever code is used into the VB app rather than the database itself though, as you suggested.
sorry about the code btw.
The extra function is here in case it helps (Bear in mind what Killer says though, it may not suit your needs directly). - 'Exist returns true if strFile exists.
-
'22/05/2003 Rewritten with better code.
-
'20/05/2005 Added finding of R/O, System & Hidden files
-
Public Function Exist(strFile As String, _
-
Optional intAttrib As Integer = &H7) As Boolean
-
Exist = (Dir(PathName:=strFile, Attributes:=intAttrib) <> "")
-
End Function
May GOD bless your holy souls !
This wish is for all who are trying to help me........................
For the auto purging data topic.....................
I think I should do it by Visual Basic................not in the database portion. I'm reading books and searching the web.In the meantime,you all also keep going.. ofcourse,if you have spare time for that.
I'll send my codes to this forum,if my project is done successfully.Cuase,it may be helpful for others.
Best regards,
Zerin
sashi 1,754
Recognized Expert Top Contributor
May GOD bless your holy souls !
This wish is for all who are trying to help me........................
For the auto purging data topic.....................
I think I should do it by Visual Basic................not in the database portion. I'm reading books and searching the web.In the meantime,you all also keep going.. ofcourse,if you have spare time for that.
I'll send my codes to this forum,if my project is done successfully.Cuase,it may be helpful for others.
Best regards,
Zerin
Hi Zerin,
Sorry for the late response, Mary had sent me a PM message to bring my attention to this thread. I think i delayed the process indirectly by not taking quick action.
Very well, since you have decided to look into VB as an option, bring the topic to VB forum, lets take a look to the best approach to solve the issue.
Take care & Have a great day ahead.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: hd |
last post by:
Are there any standard approaches used to purge records from database
in merge replication senario ?
We are using merge replication between two sql server 2000 databases.
These databasess have...
|
by: Tom |
last post by:
I am trying to store information into a table that has an auto
increment field. There is currently no data in the table. Using the
code below I cannot insert data into the table. I get an error...
|
by: Alpha |
last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key
column and the 2nd is a string. When I add a new row to the dataset to be
updated back to the database. What should I...
|
by: minapatel |
last post by:
Hi,
I am trying to purge cases using an sql cursor:-
cursor all_cases is
cursor all_cases is
select c.id00_warehouse, c.id00_case_nbr, c.id00_status_flag, c.id00_dlm
from phpick00...
|
by: Zerin |
last post by:
To all,
Best regards.I submitted this problem about auto purge a database many days ago but there's no reply till now.If anyone has any solution,please reply as soon as possible.
Is aouto...
| |
by: The Man |
last post by:
Does anyone know how to purge old data in a MS SQL server 2000
database?
|
by: bobdurie |
last post by:
Hi,
We have a Java application that runs against a variety of backends
including Oracle and MSSql 2000 and 2005. Our application has a
handful of active tables that are constantly being...
|
by: pravinnweb |
last post by:
can anyone tell me how to set auto height to outer div that is in green box id "gray-background" it should increase relatively to inner div "smbox" here is the css and html code it should work in...
|
by: saisiridi |
last post by:
i am using an mview with fast refresh.Is there any way to delete the data from Mview.Because of space constraint i cann't maintain the complete data, i want to maintain last 2 days data, is it...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |