variable is null???

  • Thread starter Thread starter Jean-Paul De Winter
  • Start date Start date
J

Jean-Paul De Winter

In following code "tezoeken" returns Null.
The recordset contains 2 records
the EOF is false

What am I doing wrong?

Dim db As Database
Dim TB_betalingen As Recordset
Dim SQL_betalingen As String, tezoeken As String
Set db = CurrentDb()

' kodelang nemen voor te printen prestaties
SQL_betalingen = "SELECT betalingen.kodelang FROM Betalingen WHERE
Betalingen.printen=True;"
Set TB_betalingen = db.OpenRecordset(SQL_betalingen)

TB_betalingen.MoveFirst

Do Until TB_betalingen.EOF

' this is the line
tezoeken = TB!KODELANG
'

DoCmd.RunSQL "Update DATA SET DATA.Printen = True WHERE
left(DATA.KODELANG,11)='" & Left(TB!KODELANG, 11) & "';"
TB_betalingen.MoveNext
Loop
 
What is "TB!KODELANG" and what, if anything, is its connection with the
recordset?

BTW: A String variable is never Null - the only variable data type that can
be Null is Variant.
 
hi Jean-Paul,

Jean-Paul De Winter said:
What am I doing wrong?
tezoeken = TB!KODELANG
Your field allows Null values, have a look at the table definition.

Use tezoeken = Nz(TB!KODELANG, "")


mfG
--> stefan <--
 
I think I found the problem...
It schould be
tezoeken = TB_Betalingen!KODELANG
instead of
tezoeken = TB!KODELANG

Kodelang is a field from the recordset...
Sorry
JP
 
Ah! Now that you mention it, it seems obvious. I think it was the defend
capitalization in the SQL statement and the assignment statement that kept
me from seeing the similarity. Anyhow, glad it worked out for you.
 
It's just not my day, is it? 'defend'? Where the heck did that come from? I
meant, of course, 'different'! :-)
 
Back
Top