Thanks for the criteria. However, I would like to delete the old records out
off the database.
I am sorry if I am asking different question.
After the user entered the CHECK OUT DATE and close the form, that record
will be deleted.
Ex: In record 10, I enter 03/24/08 in the CHECK OUT FIELD and then close it.
I would like the record 10 will be deleted by itself so that when I reopen
the form, the record 10 will be gone.
Thanks
Chi
In the OnOpen Event of the form, just above the End Sub line, add this code
Dim MySql As String
My Sql = "DELETE YourTable.* FROM YourTable WHERE
(((YourTable.YourDateFeild)=Month([YourDateField])<Month(Date())))"
DoCmd.RunSql MySql
Replace YourTable and YourDateField with the real table and field names.
You'll be sorry!
Evi
> Thanks for the criteria. However, I would like to delete the old records out
> off the database.
[quoted text clipped - 65 lines]
> > >> > Thanks
> > >> > Chi
Evi - 24 Mar 2008 20:26 GMT
If you've got any months lower than the current date from next year then
they will be deleted too so
Lets make that:
Dim MySql As String
My Sql = "DELETE YourTable.* FROM YourTable WHERE
(((YourTable.YourDateField)<DateSerial(Year(Date()),Month(Date())-1,Day(Date
()))));
(darned rosé)
Evi
> In the OnOpen Event of the form, just above the End Sub line, add this code
>
[quoted text clipped - 90 lines]
> > > >> > Thanks
> > > >> > Chi
Chi - 24 Mar 2008 20:52 GMT
Thanks Evi,
I entered the code, but I have "syntax error"
Here is the code:
Private Sub Form_Open(Cancel As Integer)
Dim MySql As String
MySql = "DELETE EQUIPMENT TABLE 2.* FROM EQUIPMENT TABLE 2 WHERE"
(((EQUIPMENT TABLE 2. CHECKEDOUT)=Month([CHECKEDOUT])<Month(Date())))"
DoCmd.RunSQL MySql
please help
Chi
> In the OnOpen Event of the form, just above the End Sub line, add this code
>
[quoted text clipped - 90 lines]
> > > >> > Thanks
> > > >> > Chi
Evi - 24 Mar 2008 21:05 GMT
If you've got gaps in your table names then you'll need to put square
backets around it
[Equipment Table 2].*
See my next letter for a better code though. Don't want you deleting future
data. And please make a copy of your db and check the query on there,
before deleting anything using a delete query. Once you say OK to it,
everything will be gone, forever!!!
Evi
> Thanks Evi,
>
[quoted text clipped - 105 lines]
> > > > >> > Thanks
> > > > >> > Chi