error handeling - beating null records...

s0rtd

Registered User.
Local time
Tomorrow, 11:54
Joined
Apr 16, 2003
Messages
96
hey guys, i am building some error handeling into my project and am wondering why this isnt working i have tried it 2 ways, this is the first:

Code:
If rst![Scheduled for] = Null Then
        GoTo NullRecord
        SkippedRecords = SkippedRecords + 1
    Else
        StartDate = rst![Scheduled for]
    End If
    
    If rst![Expected Finish Date] = Null Then
        GoTo NullRecord
        SkippedRecords = SkippedRecords + 1
    Else
        EndDate = rst![Expected Finish Date]
    End If
    
    If rst![Committed Start Time] = Null Then
        GoTo NullRecord
        SkippedRecords = SkippedRecords + 1
    Else
        StartTime = rst![Committed Start Time]
    End If
    
    If rst![Expected Finish Time] = Null Then
        GoTo NullRecord
        SkippedRecords = SkippedRecords + 1
    Else
        EndTime = rst![Expected Finish Time]
    End If

I know that the value for EndDate in the first record is blank (nothing there), when this code runs i get an error : Invalid use of null and it stops on this line
Code:
 Else
        EndDate = rst![Expected Finish Date]
    End If

i have tried changing the if statements to say this instead:
Code:
If rst![Expected Finish Time] = "" Then
- "" instead of Null

but still no luck.

i have also use this code instead, which is a lot smaller:
Code:
For Each fld In rst.Fields
         If fld.Value = Null Then
            MsgBox "null record"
        Else
        End If
            
         Debug.Print fld.Value & ";";
      Next
      Debug.Print

but still, the problem persists...

any ideas are much appreciated :)

cheer
Jurgen
 
For Each fld In rst.Fields
If fld.Value = Null Then
MsgBox "null record"
Else
End If

Debug.Print fld.Value & ";";
Next
Debug.Print

How about:

For Each fld In rst.Fields
If IsNull(fld.Value) Then
MsgBox "null record"
Else
End If

Debug.Print fld.Value & ";";
Next
Debug.Print
 
Look up help info on ISNULL. Try

if isnull(rst![Scheduled for]) = true then
else
end if

There may be better ways but the only way I've found to successfully deal with nulls is ISNULL.
 
cheers guys, this worked sweet!! :)

one more thing to remember for future :)
 
I must have used invisible ink yesterday.
freak1.gif
 

Users who are viewing this thread

Back
Top Bottom