Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    3

    Unanswered: Need to understand why a certain field name causes problems

    Hi there,

    This is my first post so please go easy on me.

    I have a weird problem that is killing my brain cells trying to understand why this happens.

    I'm using MS Access 2003. I have a backend with the data tables and frontend with the rest. I have a table called "tblProjectActions" and 3 date/time fields inside it called "DateCreated", "DateRemind", and "DateClosed" (there are other fields as well). The key field is simply an AutoNumber field.

    I have been able to use this table and its fields fine until now. I am trying to use the following code (i've simplified it to make it easier to see the weirdness):
    Code:
    Dim Db, Rs
    
    Set Db = CurrentDb
    Set Rs = Db.OpenRecordset("tblProjectActions", dbOpenDynaset)
    
    Rs.AddNew
        Rs.DateCreated = Date
        Rs.DateRemind = Date
       
    Rs.Update
    Rs.Close
    
    Set Db = Nothing
    Set Rs = Nothing
    Now comes the weirdness. I get an error message ""Operation is not supported for this type of object" when trying to run the code. The error message refers to

    Code:
        Rs.DateCreated = Date
    The problem goes away if i change the table field name to ANYTHING other than "DateCreated". Why is this? None of the other date/time fields produce this error and they are IDENTICAL in terms of their settings. If i comment out the line above, the code runs fine (ie today's date is successfully entered into a new record in the tblProjectActions table in the DateRemind field). I can't set this field to accept ANY data -- i've tried changing the field type to accept text but that doesn't help. It seems that it is the NAME of the field that is the problem.

    If i delete all the contents of the table, and try again the problem is still there. I tried using a totally new table but with the same field names and this particular name (ie "DateCreated") causes the problem. I've tried decompiling both the frontend and backend to no avail.

    Its like the name "DateCreated" has been compromised somehow, but i'm pretty sure this isn't a reserved word or anything and i've been using it fine all throughout the database.

    Help!

    I could go thru all my code and change all references to this name (to something else) but i want to know why this happens. Thanks in advance.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That's because DateCreated is an object Property in Access VBA, and it's Read-Only! From Access Help:

    DateCreated Property

    Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2008
    Posts
    3
    Quote Originally Posted by Missinglinq
    That's because DateCreated is an object Property in Access VBA, and it's Read-Only! From Access Help:

    DateCreated Property

    Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
    No wonder ! Thanks for clearing this up, i'm not losing my marbles after all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •