Results 1 to 10 of 10
  1. #1
    Cyrex is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    New England
    Posts
    5

    Access 2010 Calendar

    Hello everyone,

    I'm building a database that tracks large amounts of information per employee. The current piece I am working on is a calendar.

    At this moment, I am trying to figure out the proper code just to have it auto-populate each unbound text box with the proper date (and then have buttons to go from month to month, and possible year to year). That is my primary concern.

    I attempted the code and design from this site ( http://www.tek-tips.com/faqs.cfm?fid=838 ), and imputed it exactly as follows:

    Code:
    Private Sub form_open(cancel As Integer)
    Me![FirstDate] = Date
    Call filldates
    End Sub
    
    Private Function filldates()
    Dim curday As Variant, curbox As Integer
    curday = DateSerial(Year(Me![FirstDate]), Month(Me![FirstDate]), 1)
    curday = DateAdd("d", 1 - Weekday(curday), curday)
    For curbox = 0 To 41
    Me("D" & curbox) = Day(curday)
    Me("D" & curbox).Visible = False
    If Month(curday) = Month(Me!FirstDate) Then Me("D" & curbox).Visible = True
    curday = curday + 1
    Next curbox
    End Function
    This is the error that I have received (and no matter that I try, I can not fix it):

    Run Time Error: '2448': You can't assign a value to this object.
    I have also received errors stating that it can't find "FirstDate", but I currently can not duplicate that error.



    When I click Debug (for both the error I have quoted, and my previous error), it is the second line of code that is highlighted, as follows:

    Me![FirstDate] = Date
    I have tried a few things to try to fix it, including changing different exclamation marks to periods, and I have also replaced "Date" (in the line quoted above) to "Date()". But when I go back into the code, the parenthesis have disappeared.

    Lastly, some additional information so you know is what I plan to do with this calender:

    I intend to have the each date on the calender a field in which I can input data, and have it create it's own table. In addition, in my primary table I have dates of previous events as related to each specific employee, then when the next event will be (or has to be) by, which is 6 months out. I plan on having these dates marked automatically on the calender with the Employees name, then have that name link to linked to their Personal Record (a form labeled 'PQR').

    This is my first time posting so hopefully this information is all comprehensible!

    I look forward to your responses and if you have any questions please ask!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You cannot reference a control on a form in the Open Event as it is too early in the process. Use the OnLoad Event instead.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    No, RuralGuy, I do reference controls in the Open event. Example:
    If IsNull(![402.LabNum]) Then
    .tbxTime.Enabled = False
    .tbxCCRL.BackStyle = 0
    .tbxLab.BackStyle = 0
    .tbxC2.BackStyle = 0
    .tbxM2.BackStyle = 0
    End If

    I just tested the Me![FirstDate] = Date and it works. So something else is interfering. I have encountered that error but can't remember the circumstances and how I fixed.

    You say the textbox is unbound. FirstDate is name of textbox? Try: Me.FirstDate = Date

    Or set the DefaultValue property of unbound textbox to Date() instead of code.
    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.

  4. #4
    Cyrex is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    New England
    Posts
    5

    Still No Luck

    Thank you very much for help so far, but none of the suggestions have worked.

    I tried making it an OnLoad event, but that did not work. I also tried making it an UnLoad event (don't ask why, I just did...). Nothing.

    I have tried multiple times (before even posting my problem) changing "Me![FirstDate] = Date" to "Me.FirstDate = Date". To no avail, I tried it again after receiving your reply.

    I also tried changing the unbound text box's default property to Date()

    When I did this, I left the code as it was, and I also tried changing all of the "FirstDate"'s in the code to "Date()" as well as "Date". Still no results.

    While applying and testing those changes, I no longer received any errors. Each text box simply had this line in them:

    #Name?
    I also attempted the below on a new form with just a single unbound text box labeled "FirstDate" :

    Code:
    Private Sub form_open(cancel As Integer)
    Me![FirstDate] = Date
    End Sub
    The error I get is the one I can not duplicate on my original form and is as follows:

    Run-Time Error '2465':
    Microsoft Access can't find the field 'FirstDate' referred to in your expression.
    If you two, or any other members or admins, can offer me any more assistance, it will be greatly appreciated!!!

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Access has what is called Intellisense. When you enter Me. Access should show you all of the legal values you can type in. Does it?

  6. #6
    Cyrex is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    New England
    Posts
    5
    Quote Originally Posted by RuralGuy View Post
    Access has what is called Intellisense. When you enter Me. Access should show you all of the legal values you can type in. Does it?
    It does, but at first 'FirstDate' was not in the list. I went to the Property Sheet - Other Tab (of the 'FirstDate' Text Box), and changed the name there to 'FirstDate' and now it shows up on the list, but the code still does not work.

    It still gives me the same '2448' Run Time Error as listed in my first post.

    I really see no reason why this shouldn't work.

    Also, when I write the code as 'Me![FirstDate]', while typing that, I get no list of Legal Values.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    It is the . not ! that provokes intellisense. I use ! when referring to field names and . when referring to controls. I always give controls a meaningful name different from the field name if it is a bound control.

    I did ask you earlier if FirstDate was name of textbox. As I said I tested this code successfully. Do you want to provide project for analysis?
    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
    Cyrex is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    New England
    Posts
    5

    Calendar

    Quote Originally Posted by June7 View Post
    It is the . not ! that provokes intellisense. I use ! when referring to field names and . when referring to controls. I always give controls a meaningful name different from the field name if it is a bound control.

    I did ask you earlier if FirstDate was name of textbox. As I said I tested this code successfully. Do you want to provide project for analysis?
    A lot of the information in the database is personally identifying, so I created a new database and exported the calender to it. I then checked it to make sure it is identical to my actual database.

    Thank you very much for taking your time to help me, I do greatly appreciate it and I hope at some point in the future I'm able to return the favor.

    EDIT: This is just a rough draft of the calendar because I had deleted the form this morning and recreated it this real quick just to get a fresh start. The actual calendar is going to larger in size.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    None of the controls on the form are unbound, they all have a ControlSource. Remove it.

    Also, the textboxes 1 to 9 have a 0 in the name. Remove it. Textbox name Text5D14 should be named D14, Text35 should be D19.

    Now it works.

    You should become more familiar with debugging techniques. Check the link at bottom of my post.
    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.

  10. #10
    Cyrex is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    New England
    Posts
    5
    Thank you very much June7, my calendar now works!!!

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

Similar Threads

  1. Replies: 17
    Last Post: 08-03-2011, 05:19 PM
  2. Calendar question in access 2007
    By DPG in forum Database Design
    Replies: 6
    Last Post: 10-06-2010, 11:22 AM
  3. Access Calendar Control
    By JGG in forum Access
    Replies: 7
    Last Post: 04-03-2009, 04:34 AM
  4. Access - Calendar Control
    By James890 in forum Forms
    Replies: 3
    Last Post: 04-01-2009, 04:52 PM
  5. Export Access reports/query results to Outlook Calendar/Task
    By kfinpgh in forum Import/Export Data
    Replies: 0
    Last Post: 02-22-2007, 01:09 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