Results 1 to 6 of 6
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    open form show Month in the computer

    Hello guys
    I do not know my question true or false
    I have a form based on a table, I have this month field.
    What I want is when you open the form show me the data month. Month in the computer.
    I used this code


    Code:
    Private Sub Form_Load()
    Me.Month = Format(Date, "mmmm")
    End Sub
    But show me all months of the year.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is this Month field bound to a table field, or unbound?

    By the way, you should NOT used reserved words like "Month" for field or variable names. It can cause confusion since there is also a Month function. Choose field/variable names that are not the names of existing Access function, properties, or methods.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    JoeM is dead on about not using Reserved Words as names for Fields, Variables, etc! It confuses the Access Gnomes no end! It used to be difficult keeping track of the Reserved Words, as there are so many, but starting with v2007, if you attempt to use one when naming a Field in a Table, the aforementioned Gnomes send you an error message, explaining this to you! You really need to pay attention to these kind of warnings! Of course, if the Boys of Redmond had thought about it, they should have simply made it impossible to do it, instead of just warning you!

    I can't replicate your problem, whether the Control is Bound or Unbound, using your posted code. When things that should work don't, in Access, you have to think about corruption.

    Although we usually think of Forms, and even entire Databases, when we speak of corruption, Controls, such as Command Buttons and Comboboxes, can and do become corrupted, and seem particularly susceptible to this during app development. The test/cure for this is short and simple...delete the Control and then re-create it.
    Linq ;0)>

  4. #4
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you very much to you guys sound guidance.
    Yes field is bound, in a table.
    I've changed the label to cdMonth

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you have this code
    Code:
    Me.Month = Format(Date, "mmmm")
    you could be changing a the data in a field in a record to the month of the current date.



    But show me all months of the year.
    If you want to only display the months that match the current month, you need to set a form filter.

    Something like:
    Code:
    Private Sub Form_Load()
      Me.Filter = "cdMonth = '" & Format(Date, "mmmm") & "'"  ' this is text, so it needs delimiters
      Me.FilterOn = TRUE
    End Sub
    You should also add a button to the form to remove the filter.
    If the button name is "cmdClearFilter",
    Code:
    Private Sub cmdClearFilter_Click()
        Me.FilterOn = FALSE
    End Sub
    THIS CODE IS UNTESTED!

  6. #6
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Yes, thank you very much, my friend Steve

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

Similar Threads

  1. Replies: 21
    Last Post: 06-27-2014, 07:33 AM
  2. Replies: 1
    Last Post: 03-29-2014, 10:19 AM
  3. Open form to month or year
    By Ruegen in forum Forms
    Replies: 8
    Last Post: 09-09-2013, 06:11 PM
  4. Replies: 10
    Last Post: 06-13-2012, 05:57 AM
  5. MS Access DB will not open on new computer
    By Lunchbox in forum Access
    Replies: 3
    Last Post: 08-18-2009, 09:28 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