Problem with returning NULL (solved)
Hi
Situation:
Trying to read out of a Table(Old) to set each Fields value in another Table(New) i had to write some routines to change the values.
In this situation, after reading out 15 other fields, for this one it (below variable: tmp) returns NULL, allthough the field contains a string: "x".
The fieldName "PerDu" is a boolean field in access 2000.
--> Allthouth checking if it returns NULL, it still recieves NULL, even as it should not as that field contains a stringvalue : "x" <--
It worked previously, but thats 2 weeks ago, now i dont see why it wont work.
Maybe i just delcared somethign wrong.
Anybody see's my mistake?
Thanks
Arjuna
Hi
Situation:
Trying to read out of a Table(Old) to set each Fields value in another Table(New) i had to write some routines to change the values.
In this situation, after reading out 15 other fields, for this one it (below variable: tmp) returns NULL, allthough the field contains a string: "x".
The fieldName "PerDu" is a boolean field in access 2000.
Code:
tmp = mGetValue("perDu", i)
If BooleanHandler(tmp) = True Then
rs.Fields("PerDu") = True
Else
rs.Fields("PerDu") = False
End If
Code:
Public Function BooleanHandler(ByVal vInput$) As Boolean
' reads a string and if input contains a string longer than zero, it returns true
On Error GoTo errExit
BooleanHandler = False
vInput = Trim(vInput)
If Len(vInput) > 0 Then
BooleanHandler = True
End If
errExit:
End Function
Code:
Public Function mGetValue(vFieldName$, id, Optional optSrc$ = srcDB) As String
' Reads out a fields content of the source table,
' and returns it as string
'On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim var As Variant
Set db = CurrentDb ' Datenbank definieren
strSQL = "SELECT * FROM " & optSrc ' beliebigen SQL definieren // " & vFieldName & "
Set rs = db.OpenRecordset(strSQL) ' Recordset öffnen
rs.Move (id)
If rs(vFieldName).Value = Null Then
var = " "
Else
var = rs(vFieldName).Value
End If
mGetValue = var
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Maybe i just delcared somethign wrong.
Anybody see's my mistake?
Thanks
Arjuna
Last edited: