VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Access Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 04-12-2012, 10:22 AM   #1
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
Solved: Purging records

I keep records for about two hundred pieces of equipment. They are tracked by hours. Reports are created every 20 hours. I have created a database that stores the report results using Excel as a frontend.

Once the equipment goes in for overhaul, the previous results are no longer needed. I need to purge these records when they are less than the last overhaul time.

I get an Excel report once a month that has all the last overhaul times.

What would you recommend as the best logic to deal with these records?

I ‘m thinking about looping through the entire database, once a month, using the overhaul times report to delete all the obsolete data.


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 04-18-2012, 01:05 PM   #2
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
I would say import the report into Access and then use a query to do it. That would be the most efficient.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 04-19-2012, 06:32 AM   #3
mohanvijay
 
mohanvijay's Avatar

 
Joined: Aug 2010
Posts: 266
Kb Entries: 2
Articles: 0
Try "DELETE" statement

[code]

DELETE FROM testtable WHERE month=x and hour=y

[code]

Local Time: 12:28 AM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 12:03 PM   #4
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
OK, I'm finally back to this.

I decided to try a Delete query. It seems the simpliest and I can run it once a year.

But I can't get it to return any records.

What am I doing wrong?
Attached Images To view attachments your post count must be 0 or greater. Your post count is 0 momentarily.


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 12:34 PM   #5
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
change the second field to SOAP_table and the column to tso and then in the criteria type < [OHTime_table].[Time Last O/H]

When there are spaces in a table name you need to close them in as above.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 12:48 PM   #6
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
Now getting Data Mismatch error.
Attached Images To view attachments your post count must be 0 or greater. Your post count is 0 momentarily.


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 12:52 PM   #7
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
No wait. Changed to ONLY "< [OHTime_table].[Time Last O/H]", but no records presented.

Hmm...


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 01:00 PM   #8
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
If the whole "< [OHTime_table].[Time Last O/H]" is in quotes it will evaluate as a string. Are both fields date fields and are both serial number fields the exact same data type?

Go to sql view and post the text displayed there.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 01:08 PM   #9
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
TSO and Time Last O/h are BOTH number fields E.g. 1234.5 (Hours of run time)

Serial numbers are both text (Alphanumeric.) ABC123456

SELECT SOAP_table.*
FROM OHTime_table INNER JOIN SOAP_table ON OHTime_table.[Serial number] = SOAP_table.[SerialNum]
WHERE (((SOAP_table.TSO)<[OHTime_table].[Time Last O/H]));

And No, I did not include the quotes in the Criteria.


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 01:42 PM   #10
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
I've been looking at this TOO long.

You were right, the Serial numbers DON'T match. (One doesn't have the letter Prefix.

I'll have to edit the OHTime Excel sheet and import it again.

I'll let you know later.


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 01:57 PM   #11
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
As far as I can see that should work.

Just to clarify by type I don't necessarily mean just what is in a field but its specific type in the table definition. 123456 is a number but it can be stored in a text field or a memo field or one of many number subtypes. In access those have to match exactly to be able to link them. Otherwise you get type mismatch. Same with dates. They can be stored as dates or as strings that look like dates. In the case of ISO format they can also be stored as a number 20120521 for instance.

Sorry if I'm rambling on about stuff you already know. I just wanted to make sure you did, it would help you debug.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-21-2012, 02:16 PM   #12
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
Quote:
 
Originally Posted by: BrianMH
Sorry if I'm rambling on about stuff you already know.

Oh, Please continue.

I'm quite fluent in Word/Excel VBA, but Access seems to escape me. Probably because I don't TAKE the time to learn it. And that's a shame really, because I have several Excel databases that really should be moved to Access. Alas, one more thing on my Todo List.

After changing the serial number and re-importing, I was met with SUCCESS!!!!!!!

Went from 10 MB, down to 3MB. It had really become sluggish. (Yes, I did work on a backup!)

Thanks for your help!


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-24-2012, 07:51 AM   #13
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
Your welcome. If the thread is solved please mark it as so.

Excel is great at what it is designed for, I love it. Excel is not designed to be a database though. You will save so much time and frustration by switching to Access to use as a database. The short time it takes you to learn it will be more than made free by not trying to use a tool that isn't designed as a database as a database. I should know. I have had to design spreadsheets that work like a database too many times because a manager refuses to have access installed on a few machines. It is just a huge headache.

10MB was sluggish? That is surprising. I have databases of 600MB+ that work fine. Try adding some indexes to your tables to speed up queries. Are you running it over a network? Are you running a front end with a separate back end? There are many ways to increase efficiency.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-24-2012, 03:46 PM   #14
Tinbendr
 
Tinbendr's Avatar

 
Joined: Jun 2005
Posts: 983
Kb Entries: 0
Articles: 0
Quote:
 
Originally Posted by: BrianMH
10MB was sluggish?

Only on the Excel end as I was testing every record for < TSO. Once I purged the records, then removed the test, it was very fast. < 10 secs for everything. New Sheet, Sheet name change, added header, footer, edit margins, and then all the records.

I was toying with the idea of moving the whole thing to Access, but I get frustrated in the Form editor because I don't know my way around yet.

This success did make me get out my Access book and read a couple of chapters! There might be hope for me yet.

Thanks again!


+------+
| David |
+------+

Local Time: 12:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-25-2012, 12:18 AM   #15
BrianMH

 
Joined: Feb 2009
Posts: 481
Kb Entries: 1
Articles: 2
Check out autoforms. It helps at least get a basic design.


-----------------------------------------
The more you learn about something the more you know you have much to learn.

Local Time: 07:58 PM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Reply



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 11:58 AM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express