Help with date function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CloSeb
    New Member
    • Apr 2009
    • 1

    Help with date function

    Hello,

    I'm new to Access and I have a form called Memo. In this memo I've a date field. I want that form to be linked to my switchboard, which I know how to do, and when the switchboad opens, the form memo will open if the date specify in the date field in the memo is equal to today.

    How do I do that?

    Thanks for any help!
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    I'm no "switchboar d fan", as there's a lot of flexibility in there you don't need at all. Personally I prefer to create my own main form ("frmMain") holding the buttons arranged in the way the users expect them.
    On such a form I would "solve" your "Show the todays memo" by just adding a subform that's using a query filtering my table "tblMemo" for today's memo('s).

    Thus always the actual memo is visible and even multiple when multiple have been entered. The user won't get extracted by a "jump" to another form and the pressing of the "Close" button to proceed with his/her actual task(s).

    Getting the idea ?

    The "Switchboar d" solution would need to add VBA code to the OnOpen event of the Switchboard form and to check for a memo row for today.

    Nic;o)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      When opening the form [Memo] in the code from the Switchboard, simply specify a WhereCondition selecting only those records that match today's date :
      Code:
      strWhere = "[DateField]=Date()"
      Call DoCmd.OpenForm(FormName:="Memo", WhereCondition:=strWhere)
      NB. As Date() is recognised within SQL it need not be passed as a literal string.

      Welcome to Bytes!

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        I'll echo all of Nic;o) and NeoPa's comments and add that if your form is actually named Memo you should change that name to something else, such as frmMemo, as Memo is a Reserved word in Access, and will probably trip you up, sooner or later.

        Welcome to Bytes!

        Linq ;0)>

        Comment

        • FishVal
          Recognized Expert Specialist
          • Jun 2007
          • 2656

          #5
          "Memo" is not a reserved word in Access.

          However giving names in Hungarian notation is considered to be a good programming style and, IMHO, aesthetically pleasing. :)

          Name which starts from "frm" prefix makes evidence for you and for others looking at your code, that it refers to form object.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Originally posted by FishVal
            "Memo" is not a reserved word in Access.
            That seemed like a strange statement, so I looked for myself. Sure enough, it was listed as reserved (under "SQL Reserved Words" in Access 2003 help) :S

            Comment

            • FishVal
              Recognized Expert Specialist
              • Jun 2007
              • 2656

              #7
              Originally posted by NeoPa
              That seemed like a strange statement, so I looked for myself. Sure enough, it was listed as reserved (under "SQL Reserved Words" in Access 2003 help) :S
              Ok. My bad.
              However I can't imagine situation when form name and SQL datatype could conflict.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Originally posted by FishVal
                However I can't imagine situation when form name and SQL datatype could conflict.
                To be fair though, I don't believe anyone was saying there might be. Simply (as you expressed well in your post) that it's a good idea to avoid using reserved words generally.

                It's also a good idea for people to avoid embedded spaces in names as well as other punctuation characters. We tell them every time we get an opportunity to do so. Eventually some get it ;)

                Comment

                Working...