Results 1 to 3 of 3
  1. #1
    JosmithTwo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    19

    table field name "Year" causing Argument Not Optional

    I have a table with a field name "year". When I try to execute the following code I get "argument not optional". HOWEVER, if I run the same code and data on another Access 2007 machine, both running win XP it works just fine.

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Mo = inMonth
    Year = inYear   <<<<<<<<<<< If I change this to theYear = inYear the error goes away but the record is not updated.
    Region = Left([CustDisplay]![CUST_SLS_TERR], 1)
    Rep = [CustDisplay]![CUST_SLS_REP]
    Select Case reynCsiOpt
    Year = inYear <<<<<<<<<<< If I change this to "theYear = inYear" the error goes away but the record is not updated.

    Jim

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    This is why using reserved words as names should be avoided. Enclose in [].
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    For the future and all others looking at this thread, here a listing by MS of reserved words.

    http://office.microsoft.com/en-us/ac...010030643.aspx

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

Similar Threads

  1. ALTER TABLE does not set field "format"
    By GraeagleBill in forum Programming
    Replies: 5
    Last Post: 09-07-2012, 01:11 PM
  2. StrComp causing "Invalid use of Null" error
    By sephiroth2906 in forum Programming
    Replies: 5
    Last Post: 09-15-2011, 07:06 PM
  3. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  4. Is there such thing as "month and year as digit"
    By beejay101 in forum Queries
    Replies: 1
    Last Post: 05-16-2011, 11:28 PM
  5. Field "F1" does not exist in table (Tablename)
    By HelenP in forum Import/Export Data
    Replies: 3
    Last Post: 11-26-2010, 09:13 AM

Tags for this Thread

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