Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

NULL and empty fields

ctxctx Posts: 1Member
[b][red]This message was edited by the ctx at 2002-3-5 13:37:13[/red][/b][hr]
I have been having trouble with NULL. When I read data into the array "OutputArray," sometimes one of the fields is an empty field. The snippet below then reads the data from OutputArray into a table called "act_contacts." The array is a variant array and the fields in the table are "dbText", whatever that is.

Whenever one of the empty fields is read into act_contacts, I get the following error, which stops execution:

Runtime error '3315': Field "act_contacts.Name" cannot be a zero-length string.

Does anyone know how I can get rid of this error message and read in fields that are empty from a variant array to a table?

--------(snip)---------
Set rstContacts = CurrentDb.OpenRecordset("act_contacts")

Do While (count <= LastRecord)

objContact.GetDataEx CntInfoArray, OutputArray

'Sequentially add all ACT contacts to the temporary table
rstContacts.AddNew
rstContacts!UniqueID = CVar(OutputArray(0))
rstContacts!Name = CVar(OutputArray(1))
rstContacts!Company = CVar(OutputArray(2))
rstContacts!Phone = CVar(OutputArray(3))
rstContacts!State = CVar(OutputArray(4))
rstContacts.Update
count = cunt + 1
objContact.MoveNext
If objContact.IsEOF Then
Exit Do
End If
Loop


Comments

  • saurabh101saurabh101 Posts: 41Member
    : [b][red]This message was edited by the ctx at 2002-3-5 13:37:13[/red][/b][hr]
    : I have been having trouble with NULL. When I read data into the array "OutputArray," sometimes one of the fields is an empty field. The snippet below then reads the data from OutputArray into a table called "act_contacts." The array is a variant array and the fields in the table are "dbText", whatever that is.
    :
    : Whenever one of the empty fields is read into act_contacts, I get the following error, which stops execution:
    :
    : Runtime error '3315': Field "act_contacts.Name" cannot be a zero-length string.
    :
    : Does anyone know how I can get rid of this error message and read in fields that are empty from a variant array to a table?
    :
    : --------(snip)---------
    : Set rstContacts = CurrentDb.OpenRecordset("act_contacts")
    :
    : Do While (count <= LastRecord)
    :
    : objContact.GetDataEx CntInfoArray, OutputArray
    :
    : 'Sequentially add all ACT contacts to the temporary table
    : rstContacts.AddNew
    : rstContacts!UniqueID = CVar(OutputArray(0))
    : rstContacts!Name = CVar(OutputArray(1))
    : rstContacts!Company = CVar(OutputArray(2))
    : rstContacts!Phone = CVar(OutputArray(3))
    : rstContacts!State = CVar(OutputArray(4))
    : rstContacts.Update
    : count = cunt + 1
    : objContact.MoveNext
    : If objContact.IsEOF Then
    : Exit Do
    : End If
    : Loop
    :


    The reason for the error could be that "Name" is the primary key, so it cant be a zero length string.

    :-D [blue][b]Saurabh[/b][/blue]
    [hr]
    Saurabh Informatics
    (Custom Software Development)
    http://saurabhinformatics.com
    http://www.saurabh.info
    [hr]

  • tracykohtracykoh Posts: 6Member
    Hi,

    Another way is just to edit the properties set in your act_contacts table. Open the table in design view. Go to the designated field, eg, Name. At the field properties, set the 'Allow Zero Length' to yes. This should solve your problem.


    Tracy Koh ;-)
    IT Officer - Singapore

Sign In or Register to comment.