There is an error in the code below which returns 'OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET'

The error is due to the statusfield not being set but how do I set it?

Any help would be appreciated

Simon

For Each maxfield In MAXData.Fields
Count = Count + 1

If maxfield.Name = "dload_status" Then
strSQLstatus = "SELECT mmiss.mmiss_code" & " FROM mmiss" & "WHERE mmiss.mmiss_code =" & Chr(39) & maxfield.Value & Chr(59)
frmSearch.mmissdatasource.RecordSource = strSQLstatus
Set StatusCode = frmSearch.mmissdatasource.Recordset
frmView.MAXData(Count) = statusfield.Value
'****This line ERROR's **** ^^^^^^^^^'
Else
frmView.MAXData(Count) = maxfield.Value
End If
Next