Hi all,
I have been given a piece of code, and advised that in order to get it to work, I need to add a reference to my "DAO" in access... (my face when I read this > :-S??)
Now, i am not an advanced VBA programmer and i dont even think you would call me a beginner.
Can anyone advise me as to how and where i would add the below code to my access module?
----------
Dim Db as DAO.Database
Dim strSQL As String
'
StrSQL = "DELETE FROM RecTrans WHERE ContractNumber IN (SELECT
RECTRANS.ContractNumber
FROM RECTRANS
GROUP BY RECTRANS.ContractNumber
HAVING (((DateAdd('yyyy',7,Max([RECTRANS].[TransactionDate])))<Now())));"
'
db.Execute strSQL
strSQL = "DELETE FROM ADV WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM CBL WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM LEASE WHERE ContractNumber NOT IN (Select
ContractNumber FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM PL WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM HP WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
Set Db = Nothing
----------
I tried pasting this into my module, but it had all sorts of errors and most of the lines were red.
Thanks for reading, appreciate your time.
I have been given a piece of code, and advised that in order to get it to work, I need to add a reference to my "DAO" in access... (my face when I read this > :-S??)
Now, i am not an advanced VBA programmer and i dont even think you would call me a beginner.
Can anyone advise me as to how and where i would add the below code to my access module?
----------
Dim Db as DAO.Database
Dim strSQL As String
'
StrSQL = "DELETE FROM RecTrans WHERE ContractNumber IN (SELECT
RECTRANS.ContractNumber
FROM RECTRANS
GROUP BY RECTRANS.ContractNumber
HAVING (((DateAdd('yyyy',7,Max([RECTRANS].[TransactionDate])))<Now())));"
'
db.Execute strSQL
strSQL = "DELETE FROM ADV WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM CBL WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM LEASE WHERE ContractNumber NOT IN (Select
ContractNumber FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM PL WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
strSQL = "DELETE FROM HP WHERE ContractNumber NOT IN (Select ContractNumber
FROM Rectrans);
Db.Execute strSQL
Set Db = Nothing
----------
I tried pasting this into my module, but it had all sorts of errors and most of the lines were red.
Thanks for reading, appreciate your time.