Search code examples
ms-accessvbams-access-2010

How can I use the CDate function in an MSAccess object


I would like to update a control (in date format) to the current date and ensure that it's format is solid (e.g. not containing hours and seconds). In this example, i am trying to update the control 'AsOfDateL1'. The error message I am getting is Runtime error '6' Overflow

AsOfDateL1 = CDate(Format((Now()), yyyy / mm / dd))

Solution

  • You have to wrap the date format with double quotes if you plan to use Format like that.

    AsOfDateL1 = CDate(Format((Now()), "yyyy/mm/dd"))