Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Null values in field of recordset
Message
De
17/10/2001 18:52:24
 
 
À
17/10/2001 16:44:53
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00569912
Message ID:
00569964
Vues:
15
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform