Problem with a SQL Statement
Budget: $10 – $30 USD
This is my code:
Dim MyDate As Date
Let MyDate = Date - Me.DaysBefore 'Date of today minus the date from the unbound field of the actual form
Set db = CurrentDb
strSQL = "SELECT * FROM tblAdressen WHERE (Aktiv = -1) and (Adressart = 1) and (LetztesAuftragsdatum) < & MyDate"
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
rs.Edit
rs!InWerbebriefW = "-1"
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
The code brings an error because of the reference to the form-field. if i use only <date()>, it works
Dim MyDate As Date
Let MyDate = Date - Me.DaysBefore 'Date of today minus the date from the unbound field of the actual form
Set db = CurrentDb
strSQL = "SELECT * FROM tblAdressen WHERE (Aktiv = -1) and (Adressart = 1) and (LetztesAuftragsdatum) < & MyDate"
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
rs.Edit
rs!InWerbebriefW = "-1"
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
The code brings an error because of the reference to the form-field. if i use only <date()>, it works