Results 1 to 7 of 7

Thread: Any dbGrid Experts, Need help !

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29
    When I have data in a Grid(dbGrid) and i try to remove the cell information to leave it empty it comes back to me and say, "Field.Age can't be zero-length string". Any idea on how I can leave this field empty if user doesn't enter anything in the cell. I've tried everything and can't figure this out.

    B. Servello

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Zero Length

    Bo not think it is anything to do with dbGrid - more likely the field definiton of Age - Check the AllowZeroLength property of the field and ensure that it is set to True. If you need to set it in code it is a property of the Field in a TableDef.

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29

    Didn't work

    It didn't work.
    Can you please show me in a few lines of code what to do and have you ever seen this.

    Bruno

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    OK

    Code:
    Dim db as Database
    Dim td as Tabledef
    Dim fld as Field
    
    Set db = CurrentDb
    Set td = db.MyTable
    Set fld = td!Age
    
    fld.AllowZeroLength = True
    
    Set fld = Nothing
    etc.
    Hope it helps,

    Get back 2 u tomorrow.

    Paul
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29

    didn't work

    It doesn't work.

    B

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29

    Got Answer

    The reason why none of them were working is because you have to go to the Access file design mode ane say Yes to allow zero, not in the code.

    B

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    ZeroLength

    Certainly does work in code - easier in Design mode but I have some standard routines that examine table structures and will modify this property.

    Do not know what you tried but the code does work in the way I posted it.

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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