How can i make an error trap that would ignore any null value extracted from ms access database)?
i want my program to just ignore any null value returned and just continue as i don't have a problem for a blank data to be showed on my form.
in this code, the error highlights
.SubItems(6) = rs3!Regularization_Date
because Regularization_Date is blank on my databse. i want my program to just ignore this one and continue filling out my listview with all the data there is to show.
Private Function SearchData()
Result.Show
Result.ListView1.ListItems.Clear
Sql = "SELECT * FROM All_Employees WHERE ID LIKE '" & (Text1.Text) & "'"
Set rs3 = New ADODB.Recordset
rs3.Open Sql, con3, adOpenDynamic, adLockOptimistic
If Not rs3.EOF Then
Do Until rs3.EOF
Set lst1 = Result.ListView1.ListItems.Add(, , rs3!ID)
With lst1
.SubItems(1) = rs3!Lastname
.SubItems(2) = rs3!FirstName
.SubItems(3) = rs3!Position
.SubItems(4) = rs3!Date_hired
.SubItems(5) = rs3!Employment_Status
*.SubItems(6) = rs3!Regularization_Date*
.SubItems(7) = rs3!Office_email
.SubItems(8) = rs3!Shift_Start
.SubItems(9) = rs3!Shift_End
End With
rs3.MoveNext
Loop
End If
Set rs3 = Nothing
End Function
i just want an errortrap that would ignore all null values.
If you just want to ignore the error, you could use On Error Resume Next
Private Function SearchData()
Result.Show
Result.ListView1.ListItems.Clear
Sql = "SELECT * FROM All_Employees WHERE ID LIKE '" & (Text1.Text) & "'"
**On Error Resume Next**
Set rs3 = New ADODB.Recordset
rs3.Open Sql, con3, adOpenDynamic, adLockOptimistic
If Not rs3.EOF Then
Do Until rs3.EOF
Set lst1 = Result.ListView1.ListItems.Add(, , rs3!ID)
With lst1
.SubItems(1) = rs3!Lastname
.SubItems(2) = rs3!FirstName
.SubItems(3) = rs3!Position
.SubItems(4) = rs3!Date_hired
.SubItems(5) = rs3!Employment_Status
*.SubItems(6) = rs3!Regularization_Date*
.SubItems(7) = rs3!Office_email
.SubItems(8) = rs3!Shift_Start
.SubItems(9) = rs3!Shift_End
End With
rs3.MoveNext
Loop
End If
Set rs3 = Nothing
End Function