DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: DAO database help!!!!!!

  1. #1
    Doctordee Guest

    DAO database help!!!!!!


    Hi,
    I have made a database program using DAO 3.6 lib with my database in MS Access.
    The problem is:
    If I leave anyfield empty after entering a record, I get error "Invalid use
    of NUll". Please someone help me out.

  2. #2
    Brian Higgins Guest

    Re: DAO database help!!!!!!


    Doctordee,

    I ran into the same problem when creating records. Data placed into a text
    field apparently cannot be null or an emply string. Therefore, before entering
    information into a field, I check to see if it null or an emply string --
    if so, I convert it to an single space string. For my purposes this seems
    to work. However, I am new to using DAO and this may not be the "proper"
    solution.

    "Doctordee" <drlamba_d@rediffmail.com> wrote:
    >
    >Hi,
    >I have made a database program using DAO 3.6 lib with my database in MS

    Access.
    >The problem is:
    >If I leave anyfield empty after entering a record, I get error "Invalid

    use
    >of NUll". Please someone help me out.



  3. #3
    huibert Guest

    Re: DAO database help!!!!!!


    "Doctordee" <drlamba_d@rediffmail.com> wrote:
    >
    >Hi,
    >I have made a database program using DAO 3.6 lib with my database in MS

    Access.
    >The problem is:
    >If I leave anyfield empty after entering a record, I get error "Invalid

    use
    >of NUll". Please someone help me out.


    This is the result of the fact that in your table design, the 'required'
    property for those fields is set to 'yes'. This means that a value must given
    for those fields. To change this Start Access, Select the table, choose design,
    select the fields and change 'required' to 'no'.

    HTH
    huibert

  4. #4
    Brian Higgins Guest

    Re: DAO database help!!!!!!


    "Doctordee" <drlamba_d@rediffmail.com> wrote:
    >
    >Hi,
    >I have made a database program using DAO 3.6 lib with my database in MS

    Access.
    >The problem is:
    >If I leave anyfield empty after entering a record, I get error "Invalid

    use
    >of NUll". Please someone help me out.


    There may be another solution. If the database is created within VB6 code,
    the user cannot open up Access and change a field parameter as the db is
    being created with the code. However, the property AllowZeroLength may provide
    the solution. The following from the MSN documentation about the DAO 3.60
    may help...

    AllowZeroLength Property Example

    In this example, the AllowZeroLength property allows the user to set the
    value of a Field to an empty string. In this situation, the user can distinguish
    between a record where data is not known and a record where the data does
    not apply.

    Sub AllowZeroLengthX()

    Dim dbsNorthwind As Database
    Dim tdfEmployees As TableDef
    Dim fldTemp As Field
    Dim rstEmployees As Recordset
    Dim strMessage As String
    Dim strInput As String

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    Set tdfEmployees = dbsNorthwind.TableDefs("Employees")
    ' Create a new Field object and append it to the Fields
    ' collection of the Employees table.
    Set fldTemp = tdfEmployees.CreateField("FaxPhone", _
    dbText, 24)
    fldTemp.AllowZeroLength = True <--- this may solve your problem
    tdfEmployees.Fields.Append fldTemp



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center