variable is null???

  • Thread starter Jean-Paul De Winter
  • 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
 
B

Brendan Reynolds

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.
 
S

Stefan Hoffmann

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 <--
 
J

Jean-Paul De Winter

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
 
B

Brendan Reynolds

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.
 
B

Brendan Reynolds

It's just not my day, is it? 'defend'? Where the heck did that come from? I
meant, of course, 'different'! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top