Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Delete Query with Square Brackets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Glenn Peters - 05 Nov 2005 16:16 GMT
Hey guys

Im trying to create a delete query using square brackets. The idea is
that it will delete records older than the number of years that the user
 inputs when the query is run.

This is what i have so far

<=Now()-[Years?]

It seems to work fine, eg when i run it, the box appears and i can type
something in. Only problem is, i cant type the number of years, i have
to type the number of DAYS in years to make it work.

For example, i tired to delete records older than 3 years. I cant type
the number '3' i have to type 1095.75 days!

If you could tell me how to change this so i can just type the number of
years instead of the number of days id really appreciate it.

Thanks

G
Duane Hookom - 05 Nov 2005 16:45 GMT
You can change your query to calculate the years difference as a column:

YearsDiff: DateDiff("yyyy", [Your Date Field Name], Date())
Then set the criteria to
>=[Enter the number of years]

I would allow the user to enter a date into a control on a form and then
delete records earlier than the date:

WHERE YourDateField <=Forms!frmEnterDate!txtDate

Signature

Duane Hookom
MS Access MVP

> Hey guys
>
[quoted text clipped - 19 lines]
>
> G
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.