Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum=" &
!datum)
I have never seen this type of syntax. Usually it is "Me.datum" or Forms!FormName!datum or Forms!FormName.datum
(Maybe you could use it inside a With ... End With block)
Code:
Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum = " & Me.datum)
Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum = " & Forms!FormName!datum)
Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum = " & Forms!FormName.datum)
(change FormName to your form name)
If you want to see if there are in fact records for a datum = 4, then try
Code:
Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum = 4 ")
and check q.recordcount.
If you use the above syntax, "WHERE Datum = 4", and add a record using
Code:
Dim q As DAO.Recordset
Set q = CurrentDb.OpenRecordset("SELECT * FROM TabelDone WHERE Datum=4")
q.AddNew
q!datum = 7
q.update
q.requery
If you then check the recordcount ,q.RecordCount will not reflect the newly added record because datum = 7 (and not 4)