Results 1 to 4 of 4

Thread: Handling Nulls

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Posts
    161
    I am using RDO to retrieve data from an Access database. When the data comes back, I need to handle the fact that some fields are 'Null'.

    I try to core the following:

    If RS1.Fields("SECONDARY_DIE") Is Null Then
    txtSECONDARY_DIE.SetFocus
    Else
    txtSECONDARY_DIE.Text = RS1.Fields("SECONDARY_DIE")
    txtSECONDARY_DIE.Locked = True
    End If

    ... and get an error at the first line: 'Object required'. The field is empty and I really don't get what I am doing wrong.

    Can anyone help on that ?

    Thanks,
    Francis


  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    If you want to check for a null, try the isNull function.

    Code:
    If isNull(variable) Then
      MsgBox "Variable is null."
    End If
    Hope this helps.

  3. #3
    Addicted Member jcouture100's Avatar
    Join Date
    Aug 1999
    Posts
    141
    Stevie is correct. You need to use the isNull function. I think your error is generated by the isNull being in the wrong location. Your code is very close. Change it to look like this...

    Code:
    If isNull(RS1.Fields("SECONDARY_DIE")) Then 
        txtSECONDARY_DIE.SetFocus 
    Else 
        txtSECONDARY_DIE.Text = RS1.Fields("SECONDARY_DIE") 
        txtSECONDARY_DIE.Locked = True 
    End If
    JC

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Or if you want to add recordset value to a Textbox, you can use this trick:
    Code:
    Text1.Text = "" & rs("FieldName").Value
    This way you won't get an error saying that you cannot assign NULL to the Textbox.

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