Results 1 to 9 of 9
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,095

    Fields property via TableDefs not recognized

    With the snipit of code below, the modules error code reports that "Format" is not a recognized property. The field "Deceased" was added okay via the ALTER TABLE, but trying to change the table def to format the field as Yes/No fails.

    Code:
        strDDL = "ALTER TABLE Registry ADD Column Deceased YESNO False"
        conBackend.Execute strDDL, dbFailOnError
        CurrentDb.TableDefs("Registry").Fields("Deceased").Properties("Format") = acCheckBox

    Anyone know what it should be?
    Thanks,


    Bill

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Code:
    Sub testddl_Jed()
       Dim strddl As String
        strddl = "ALTER TABLE Registry ADD Column Deceased YESNO False"
        CurrentDb.Execute strddl, dbFailOnError
        CurrentDb.TableDefs("Registry").Fields("Deceased").Properties("Format") = acCheckBox
    End Sub
    I ran the first 2 lines of your code and all is well.
    The format property of the Deceased field :
    Code:
       
    True/False
    Yes/No  
    On/Off
    The third line results in 3270 Property not found.


    Are you thinking of adding a checkbox control on form and setting its control source to the field Deceased??

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Found this at Allen Browne's site
    http://allenbrowne.com/func-DDL.html#CreateFieldDDL

    (I added the bold blue hi-light)
    While DDL is important in some larger databases, it is of limited use in Access. You can create a Text field, but you cannot set the Allow Zero Length property to No, so any query criteria must test for both Nulls and zero-length strings. You can create a Yes/No field, but you get a text box, not a check box, since you cannot set the Display Control property with DDL. You can create a Date/Time field, but you cannot set the Format property. DDL cannot create Hyperlink fields, Attachment fields, or the complex data types at all.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,095
    Are you thinking of adding a checkbox control on form and setting its control source to the field Deceased??

    I already have and that's not the problem. I just wanted the table display to show check boxes versus 0 and -1.
    Like you see for the fields PubCell and PubEMA in the screenshot below.
    (I also want to do the same for the field SecurityCL where you also see as 0 and -1)

    Click image for larger version. 

Name:	CheckBoxes.jpg 
Views:	17 
Size:	45.1 KB 
ID:	22532

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I think Steve has the answer. Not availble via DDL.

    I tried to create the Property "Display Control", then set it to acCheckbox, but Property Not Found results.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,095
    I won't mark the thread as "Solved", but I'm not going to spend any more time on the issue.
    Thanks for your effort.
    Bill

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Hi Bill! I suspect others have identified the problem (I've never worried about the format in the table), but I'd wonder if conBackend was different than CurrentDb:

    conBackend
    .Execute strDDL, dbFailOnError
    CurrentDb.TableDefs("Registry").Fields("Deceased").Properti es("Format") = acCheckBox

    In other words, it appears you are trying to apply the format to a linked table (CurrentDb) rather than the actual back end table conBackend). Maybe that's just me making wrong assumptions based on the variable name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I did find a reference that said in Acc 97 Display Control for YesNo field as a checkbox was a default.
    Probably deprecated?? I don't use it, but haven't looked too much.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,095
    Hi Paul,
    I'll play with this as time allows. Allen has more examples on subjects such as this one.
    I only address things like this where DB field updates become an issue among users that look at tables.
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Item Not Found In Collection For TableDefs
    By gammaman in forum Modules
    Replies: 2
    Last Post: 06-17-2015, 07:55 AM
  2. Why blank fields are not recognized.
    By Luvflt in forum SQL Server
    Replies: 16
    Last Post: 04-08-2015, 11:54 AM
  3. tableDefs displaying Tables not there
    By JosmithTwo in forum Programming
    Replies: 3
    Last Post: 08-04-2012, 09:12 AM
  4. Working with TableDefs
    By farssr in forum Programming
    Replies: 2
    Last Post: 03-14-2011, 07:17 PM
  5. TableDefs.Delete
    By DaveE in forum Programming
    Replies: 3
    Last Post: 10-31-2010, 07:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums