Results 1 to 5 of 5

Thread: Simple Access Question

  1. #1
    Guest

    Unhappy

    I'm having the following problem with Access 97 and VB:

    I'm using a TableDef to change the default values of various
    fields in the database. The fields are text fields, 255
    characters max, allowing empty strings, and not required.
    I'm assigning the .fields(X).defaultvalue property to the
    .text property of a listBox.

    If I change the default value to an alpha string like
    "Platinum", then it works fine. However, if I use a string
    which begins with a number like "14 Karat" then I get a
    Syntax error in "...table level validation".

    Since this is obviously a program for a jeweler, most of the
    strings will look like 14XXX or 18XXX or 22XXX.

    The solution seems deceptively simple. Can anyone help?

    -John

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    I have only one idea. In Access open design of your table and create Input Mask for this field.

  3. #3
    Guest
    That doesn't do it. By leaving the input mask blank it allows any input to the field(I think). Anyway, I can't type the string 14K into the default value box even if I try to do it right in Access. Try it yourself, it's pretty odd.


    -John

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    When are you typing in the default box, do you inclose your string in double quotes? Like "14K". Do you have any validation for this field in Access( validation text, validation rule)?

  5. #5
    Guest
    LG-

    I finaly got it solved, but i had to use

    myTableDef.defaultvalue = chr(34) & "14K" & chr(34)

    to get the quotes into Access properly. I need a refresher
    on escaping quotes in strings, I guess. Thanks for the
    help on this.

    -John

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