Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Null values in field of recordset
Message
From
17/10/2001 18:52:24
 
 
To
17/10/2001 16:44:53
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00569912
Message ID:
00569964
Views:
14
>Dim cnSMDR1 As Connection
>Dim rsCodes As Recordset
>Private Sub Form_Load()
>Dim NewItem As ListItem
> Set cnSMDR1 = New Connection
> cnSMDR1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Tracit\SMDR1.mdb"
> Set rsCodes = New ADODB.Recordset
> rsCodes.CursorLocation = adUseClient
> rsCodes.Open "Codes", cnSMDR1, adOpenStatic, adLockOptimistic
>
> listNxx.ListItems.Clear
> txtNpa = ""
>End Sub
>Private Sub Search_Click()
>rsCodes.Filter = "NPA =" & (txtNpa.Text)
>Do While Not rsCodes.EOF
> Set NewItem = listNxx.ListItems.Add(, "A" & rsCodes("NXX"), rsCodes("NXX"))
> NewItem.SubItems(1) = rsCodes("RC")
> NewItem.SubItems(2) = rsCodes("State")
> rsCodes.MoveNext
> Loop
>End Sub
>
>The above code for a listbox occasionally runs across a null value in the rsCodes(RC) field. How would you suggest I skip any records containing null values in this field?

You could probably do something like:
Do While Not rsCodes.EOF
   If Not IsNull(rsCodes("RC")) Then
      Set NewItem = listNxx.ListItems.Add(, "A" & rsCodes("NXX"), rsCodes("NXX"))
      NewItem.SubItems(1) = rsCodes("RC")
      NewItem.SubItems(2) = rsCodes("State")
   End If
   rsCodes.MoveNext
Loop
HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform