Results 1 to 6 of 6

Thread: FIELD WITH LENGTH ZERO, FIELD NULL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Sao Paulo - SP - BRAZIL
    Posts
    65

    Post

    Before recording them I register I move like this the fields

    rs.Fields ("te_nome ") = txtnome
    rs.Fields ("te_endereco ") = txtender
    rs.Fields ("te_bairro ") = txtbairro
    rs.Fields ("te_cep ") = TDBMSKCEP
    rs.Fields ("te_municipio ") = txtmunicipio
    rs.Fields ("te_uf ") = DBCMBUF
    rs.Fields ("te_telefone ") = tdbmskfone
    rs.Fields ("do_sequencia ") = DBCombo1.Text

    when I will record it gives the following message:

    The field <name of the field> it cannot be a sequence of characters of length zero
    I already tried to do the following:
    rs.Fields ("te_bairro ") ="" & txtbairro

    but doesn't it also work, as I should proceed?


    ------------------
    The blessing of God enriches and it doesn't increase pains

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    Are you totally sure that the txtbairro variable is definitely not empty or zero-length? Have you used the debugging tools in VB and set up a watch on txtbairro, then stepped through the program, line by line?

  3. #3
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Text fields have to be between ' or " (not sure which one it is for Access, SQL server uses '), and set the AllowZeroLength property to true if possible (allow Null values)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Sao Paulo - SP - BRAZIL
    Posts
    65

    Post

    Excuse me , but txtnome, txtbairro are controls with data and some do not have data are null

    How do I do to record these data?

    ------------------
    The blessing of God enriches and it doesn't increase pains

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I set up a function to handle nulls for databases:

    Function nonulls(s As Variant) As String
    '- string = NoNulls(string)
    'Checks to see if the string passed is null, if so then return "" else return
    'the passed string. A wrapper for access stuff.
    If IsNull(s) Or Len(s) = 0 Then
    nonulls = ""
    Else
    nonulls = s
    End If
    End Function


    then I use it like this:

    rs.Fields ("te_nome ") = nonulls(txtnome)

    this will check if txtnome is empty(null), if it is, it will send back a blank string which the database can understand. Question though, do the fields that have empty text boxes have their AllowedZeroLength set to yes? That will stop it as well.


  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Do this. rs.Fields ("te_bairro") = txtbairro & " " (I've changed your "" to " "). When you read in the data use RTRIM to strip off the space at the end.

    ------------------
    Marty

    [This message has been edited by MartinLiss (edited 01-19-2000).]

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