Using a Macro to Add a Date in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flabbers11
    New Member
    • Jul 2008
    • 7

    Using a Macro to Add a Date in Access

    Hi,
    Im wondering if i can use a macro so when a Menu Button is pressed it adds the current date to the currently selected cell?
    Ive tried using Now() and assigning it to the Properties of the menu button ive made but it doesnt work.
    Any Suggestions?
    Thanks in advance,
    Sam
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Hi Sam,

    Probably best to use VBA code to do this.
    Just place in the OnClick event of the button a Procedure and use the line:
    Code:
    Me.FormFieldname = Now()
    Me.Refresh
    Best to have a separate button for each date field.

    Personally I often use a calendar control, thus making it possible to "click a date" instead of typing...

    Nic;o)

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Originally posted by flabbers11
      Hi,
      Im wondering if i can use a macro so when a Menu Button is pressed it adds the current date to the currently selected cell?
      Ive tried using Now() and assigning it to the Properties of the menu button ive made but it doesnt work.
      Any Suggestions?
      Thanks in advance,
      Sam
      You should use Date() function, which returns current date with zero time, if you want later to search/filter the table with criteria containing only m/d/y portion of date.

      Regards,
      Fish

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        Originally posted by flabbers11
        flabbers11: Ive tried using Now() and assigning it to the Properties of the menu button ive made but it doesnt work.
        Personally, I'd use Date() rather than Now(), assuming it's the current date you require.

        That said, your requirement determines whether it's better simply to set the .Default property of the control, or to update the value on some sort of event. As you haven't shared that information with us we can't lead you further.

        Comment

        Working...