Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164

    New compile error on old form

    Hi Everyone,



    I've recently had a rather odd compile error crop up in one of my existing forms. I have a series of dates that define academic season start and end dates. All variables are defined as dates and, what is extra weird, I've been running this code since I first developed this form almost a year ago. This code is triggered by the Form_Current event. The code is below:
    Code:
    ThisYear = Year(Date)
         'Setting date range variables such that only the year in the SpringStart variable needs to be changed
         SpringStart = DateSerial(ThisYear, 1, 1)
         SummerStart = DateAdd("m", 6, SpringStart)
         FallStart = DateAdd("m", 2, SummerStart)
         FallEnd = DateAdd("yyyy", 1, SpringStart)
    The compile error I get is "Wrong number of arguments or invalid property assignment" and it highlights the DateAdd function assigning a value to SummerStart.


    The only thing I've changed to the form is to add some additional functions, specifically a button that launches a related form for additional data entry. If anyone understands what is going on here I would sincerely appreciate a little insight. Thanks!

    Ryan

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Have you been able to pin down the circumstances that trigger this error? Does it happen for every record? Have you step debugged?
    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
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    I get the error whenever I try to open the form. Even when I add breakpoints to try and step through the code, the compiler won't let the code execute. Or am I thinking of the wrong event? Should I try inserting break points into the Form_Load event?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Are you sure the SpringStart variable gets properly set?

    The compiler bugs on the Current event so comment the code and see if the form opens.

    Possible form or control on form is corrupted. Could try building a new one. Rename the original, create new form with the original name, copy paste controls and code. Same error?
    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.

  5. #5
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    I managed to insert break points in the Form Open section, and while I was stepping through the code the system locked up. It was in break mode but would not reset. Eventually the program unexpectedly quit. Would this indicate to you the form is corrupted? I will try replacing the form.

  6. #6
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Okay, nope. Copy and pasted both controls and code and I still get the same compile errors. The code works if I comment out all references to these dates but that in itself is rather frustrating. As I said this has operated just fine for about a year and is only now becoming a problem. I have checked to ensure the starting date SpringStart is getting set as 1/1/2013. I am not sure how this is going so wrong but I will keep plugging away. If I hit upon a solution I will post it here.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Have you tested on different machine?

    Don't know how adding some functions could have caused issue but do you have a copy from before that you can test? Then repeat the mods incrementally. When does the error pop up?
    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.

  8. #8
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Well this is frustrating. Now this compile error is showing up on every form that uses a DateAdd function. Ugh...I use this quite often since a lot of the records I'm dealing with involve notifying students of various things based on either what season it currently is or what season they will graduate it.

  9. #9
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    I've got an older copy of the dbase that doesn't cause this error. However, when I copy and paste the form/code I get the same compilation errors.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Do any other date functions cause problems?

    Have you tested on another computer?

    Does VBA list any MISSING references?
    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.

  11. #11
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    DateSerial works like a champ. I have noticed that the IntelliSense feature that displays the required arguments for each function does not work with DateAdd on my machine. The DateAdd feature fails in every piece of code I have it in, which is a lot.

    I have also tested an older version of this dBase on my computer and those same DateAdd functions work just fine. As for missing references, I don't know where these would be listed.

  12. #12
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Okay so in the short term I've learned to live without DateAdd. I have solved most of my problems using addition within DateSerial. For example:
    Code:
    ' previous method
    SpringStart = DateSerial(Year(Date),1,1)
    SummerStart = DateAdd("m",6,SpringStart)
    ...
    ' previous method in other code
    DueDate = DateAdd("d",2,Date)
    
    
    ' current method
    SpringStart = DateSerial(Year(Date),1,1)
    SummerStart = DateSerial(Year(Date),7,1)
    ...
    ' current method in other code
    DueDate=DateSerial(Year(Date),Month(Date),Day(Date) + 14)
    It's not as elegant, I know. I especially mourn the loss of features like weekday or day of year in DateAdd. I will have to take my code apart to see what is wrong but at least I can keep things running this way.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    VBA references - from the VBA editor menu: Tools > References
    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.

  14. #14
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Can I mark this thread as solved-ish?

  15. #15
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    June,

    I'm showing the following references as checked:
    * Visual Basic for Applications
    * Microsoft Access 14.0 Object Library
    * OLE Automation
    * Microsoft Office 14.0 Access database engine Object
    * Microsoft Word 14.0 Object Library
    * Microsoft ActiveX Data Objects Recordset 2.8 Library
    * Microsoft Outlook 14.0 Object Library
    * Microsoft Excel 14..0 Object Library
    * Microsoft ADO Ext. 2.8 for DDL and Security
    * Microsoft Internet Controls
    * Microsoft Windows Image Acquisition Library v.20

    Are there some I should see here that I'm not?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM
  3. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  4. Replies: 6
    Last Post: 09-28-2011, 09:20 PM
  5. Replies: 1
    Last Post: 04-24-2010, 09:57 AM

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