"DL" <da*******@hotmail.com> wrote in message news:<40*********************@news.wanadoo.nl>...
Hi when I try to run this to check if there will be a duplicate entry when
doing an INSET sql I get a mssg saying that there is the datafield is empty
(because the SQL_Str does not return anything). But I do not want it to say
that and start debugging.
If dubbel = "yes" it should not run my SQL INSERT query and otherwise it
should, instead of saying it cannot find anything...
Set dbs = CurrentDb
Set Some_Recordset = Recordset
SQL_Str = "SELECT Datum FROM TijdRegistratie WHERE Datum= #" & [datumveld] &
"#"
Set Some_Recordset = dbs.OpenRecordset(SQL_Str)
If Some_Recordset!Datum Then dubbel = "yes"
suggestions??
DL
It looks like this is what you are trying to do:
....
Set Some_Recordset = dbs.OpenRecordset(SQL_Str)
dubbel = "yes"
If Some_Recordset.RecordCount = 0 Then dubbel = "no"
Some_Recordset.Close
Set Some_Recordset = Nothing
If dubbel = "no" Then
'Code/SQL to insert record with a unique date into TijdRegistratie
End If
....
Note that when the RecordCount is 0 the .MoveLast normally required to
get a reliable number is not necessary. Also, even if you retrieved a
date with your original code without a .MoveFirst, the 'If
Some_Recordset!Datum' part of your code would try to convert your date
value into a Boolean value -- definitely not what you want.
James A. Fortune