Results 1 to 8 of 8

Thread: see if field is null

  1. #1
    scoutt
    Guest

    see if field is null

    hello everyone,

    I am trying to load a treeview (ya still) and I get it to load the child no problem, but I want to load the field that is empty as a folder child. this is my code.
    Code:
    Dim SelectString As String
    	  SelectString = "Select * from Routine where [Counter]= " + Label2
    	  Set rsFiltered = dbName.OpenRecordset(SelectString)
    	 Do While Not rsFiltered.EOF
    	  'Add routine nodes
    	  If rsRoutines.Fields("ParentID") > "0" Then
              tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
              tvwChild, "Routine" & rsFiltered("counter"), _
    	  rsFiltered("Routine"), "code", "codered"
    		 
    		 'Else
    		 If rsRoutines.Fields("Description") = Null Then
    	tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
            tvwChild, "Routine" & rsRoutines("counter"), _
    	  rsRoutines("Routine"), "closed", "open"
    		  End If
    	  End If
    		rsFiltered.MoveNext
    	  Loop
    		rsRoutines.MoveNext
      Loop
    
    'Code improved by vBulletin Tool (Save as...)
    ok it loads child nodes if the field ParentID > 0, but the folder child I want to load is also greater than 0 so I was trying to load it by another field. I don't think this is working because it already loaded it in the previous if..then statement.

    How do I change it to load if ParentID > 0 but if the Description field if empty to load it as folder child. does any of that make since?

    TIA

  2. #2
    Jethro
    Guest
    No doesn't make sense????

    If Len(Trim(stringhere)) > 0 Then

    any help?

  3. #3
    Megatron
    Guest
    Use the IsNull function to determine if it's null
    Code:
    If IsNull(rsRoutines.Fields("Fld")) Then MsgBox "Null"

  4. #4
    Jethro
    Guest
    Originally posted by Megatron
    Use the IsNull function to determine if it's null
    Code:
    If IsNull(rsRoutines.Fields("Fld")) Then MsgBox "Null"
    Was thinking of that, but wasn't sure if it was fully functional in vb6 yet. The function IIF occasionally turns up really weird results so have keeped clear of IsNull

    COuld you restate the line as

    If IsNull(rsRoutines!Fld) Then Msgbox "***"

    just a thought.

  5. #5
    Megatron
    Guest
    Originally posted by Jethro
    Was thinking of that, but wasn't sure if it was fully functional in vb6 yet.
    It works fine in VB5, so I presumed that it would work in VB6 as well.

  6. #6
    scoutt
    Guest
    ok I can see what you guys are talking about but,,

    let me see if I can explain this better. this is an excert from another thread I was having Techman helping on. maybe Null was not what I was after.

    When stored in the database the main root folder has a ID (counter, 100 for eg.), but it also has a ParentID (0) to make it the root folder. so if a new folder is under that folder it would have the ParentID of the folder it is under (100) and then it would have a regular counter key another number. so all folders under the main root folder would have a ParentID (reference key) of 100 as that of the root folder. if you want ot read more about an see some pictures, read this post
    that might help explain what I'm doing.

  7. #7
    scoutt
    Guest
    ok still a little confusing??

    let me re-word the question.

    How can I insert a field from a DB that is empty in to the tree as a child from the code above. I tried this
    Code:
    If IsNull(rsRoutines.Fields("Description")) Then
          tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
          tvwChild, "Routine" & rsFiltered("counter"), _
         rsFiltered("Routine"), "closed", "open"
    but it comes back and tells me "element not found" and highlights the code above but points to the bold line.

  8. #8
    scoutt
    Guest
    back to top

    anybody??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width