Avatar of Paul McCabe
Paul McCabe
 asked on

Filtering a Continuous Form by Date Ranges in VBA

I am an MS Access beginner using version 2013. A button opens a continuous form that I would like to filter for records in the range of ten days before the current date and 30 days after the current date (i.e. a 40-day period). I have tried various pieces of code for the button's on-click event, including the following, but just cannot get it to work.

DoCmd.OpenForm " Form_Projects", , , "Date= Between Date()-10 And Date()+30"

The expression Between Date()-10 And Date()+30 works fine in queries, but not in VBA, as I keep getting an error message telling me the code structure is wrong. Could anyone help point me in the direction of the correct VBA expression that should be used ?
Microsoft AccessVBA

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon
SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rey Obrero (Capricorn1)

or possibly

DoCmd.OpenForm " Form_Projects", , , "[Date] >= "#" & Date()-10 & "#" And [Date] <= "#" & Date()+30 &"#""
Paul McCabe

ASKER
Roy's first solution and Dale's suggested solution worked fine. Dale, your points are well made. Thank you both !
Dale Fye

glad to help.
Your help has saved me hundreds of hours of internet surfing.
fblack61