473,486 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Auto Purging data

Zerin
64 New Member
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
Dec 13 '06 #1
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
Dec 13 '06 #2
NeoPa
32,556 Recognized Expert Moderator MVP
If you are trying to purge unused data from your database this function should work for you.
Expand|Select|Wrap|Line Numbers
  1. 'CompactDb compacts a remote Access database.
  2. Public Function CompactDb(ByVal strDB As String, _
  3.                           Optional strPW As String = "") As Boolean
  4.     Dim strNewDB As String, strLocale As String
  5.  
  6.     On Error GoTo ErrorCDB
  7.     strNewDB = Replace(strDB, ".Mdb", "New.Mdb")
  8.     Call Echo(True, "Compacting """ & strDB & """.")
  9.     If strPW <> "" Then strLocale = ";pwd=" & strPW
  10.     If Exist(strNewDB) Then Kill strNewDB
  11.     Call DBEngine.CompactDatabase(SrcName:=strDB, _
  12.                                   DstName:=strNewDB, _
  13.                                   DstLocale:=strLocale, _
  14.                                   SrcLocale:=strLocale)
  15.     Kill strDB
  16.     Name strNewDB As strDB
  17.     Call Echo(True, """" & strDB & """ compacted.")
  18.     CompactDb = True
  19.     Exit Function
  20.  
  21. ErrorCDB:
  22.     CompactDb = False
  23. End Function
If not, then please explain your question more clearly so we can help you.
Dec 14 '06 #3
Zerin
64 New Member
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
Dec 20 '06 #4
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.

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.    strSQL = "DELETE * FROM TableName;"
  4.    DoCmd.RunSQL
  5.  
  6.  
should do the job.

Mary
Dec 20 '06 #5
Zerin
64 New Member
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
Dec 21 '06 #6
Zerin
64 New Member
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
Dec 21 '06 #7
Zerin
64 New Member
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
Dec 21 '06 #8
Killer42
8,435 Recognized Expert Expert
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.
Dec 22 '06 #9
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
Dec 22 '06 #10
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
Dec 22 '06 #11
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).
Expand|Select|Wrap|Line Numbers
  1. 'Exist returns true if strFile exists.
  2. '22/05/2003 Rewritten with better code.
  3. '20/05/2005 Added finding of R/O, System & Hidden files
  4. Public Function Exist(strFile As String, _
  5.                       Optional intAttrib As Integer = &H7) As Boolean
  6.     Exist = (Dir(PathName:=strFile, Attributes:=intAttrib) <> "")
  7. End Function
Dec 22 '06 #12
Zerin
64 New Member
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
Dec 28 '06 #13
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.
Dec 28 '06 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1915
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...
2
12699
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...
6
5050
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...
10
3230
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...
4
1239
Zerin
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...
1
7371
by: The Man | last post by:
Does anyone know how to purge old data in a MS SQL server 2000 database?
3
3892
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...
1
5141
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...
0
1236
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...
0
7123
Oralloy
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,...
0
7175
jinu1996
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...
1
6842
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...
0
7319
tracyyun
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...
0
5430
agi2029
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,...
1
4864
isladogs
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...
0
262
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.