1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

AllowZeroLength property

Discussion in 'Business Applications' started by magadraw, Apr 28, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. magadraw

    magadraw Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    5
    Is there a way to programmatically set the AllowZeroLength property for a field in an Access database using VBA? I have been looking and it seems possible, but I'm not sure of the syntax. Any help would be greatly appreciated.

    Thanks in advance,
    Scot
     
  2. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    If what you are asking is can you require a field to be filled out even if you have set Required=No and AllowZeroLength=Yes in the table properties, the answer is yes. You can do this in the form design using vb/vba code.

    If me.form_fieldname="" then msgbox "You must fill in the XXX field", vbokonly
    me.form_fieldname.setfocus

    The tricky part is getting the requirement to fire under all possibilities. One obvious spot is in the LostFocus, another might be in BeforeUpdate...and then just test like crazy and try filling in the info as incorrectly as possible to try to trigger it. This way you'll also be able to see when it doesn't fire but should.

    Hope this helps,

    MBN
     
  3. magadraw

    magadraw Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    5
    Thanks for the reply, but what I really want is to change the AllowZeroLength property on a table that already exists from No to Yes. I have a database that has fields already defined in multiple tables and I need to change the property using vba.

    Any help on that end?

    Thanks,
    Scot
     
  4. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    I guess I don't understand why you don't go into the table properties and change it straight out?
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/224715

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice