"Previous Month" in VBA for Access

Discussion in 'Software' started by Allochthonous, Sep 9, 2006.

  1. Allochthonous

    Allochthonous Corporal

    Does anyone here know an easy way to get two fields on an Access form to populate with the first day and last day of the previous month by the click of a button?

    Here is the best I could come up with, but this seems so sloppy:

    (of course, this is on the OnClick event on the button)

    Dim TheDate As Date
    Dim DaysBack As Integer


    TheDate = Date 'uses TheDate so that I can enter any date for testing


    DaysBack = (DatePart("d", (Date)))

    [End] = (TheDate - DaysBack)

    [Start] = (TheDate + 1) - (DaysBack + (DatePart("d", [End])))
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds