hesykhia
03-23-2016, 10:09 AM
Hey guys! So I'm trying to figure out the best way to write some VBA code for a query/report.
I have a form where there are boxes where a user can select dates, and then if you click the button above it, it opens a report that has records that are between those two dates. Here is the code I'm using for that:
DoCmd.OpenReport "BENsReportCassieM", acViewReport, , "[DateWorked1st] >= #" & Forms!CassieMTotalsForm!BENsSDate & "# And [DateWorked1st] <= #" & Forms!CassieMTotalsForm!BENsEDate & "#"
The issue I'm having is, there is a second field I need it to look at as well, a second date (DateWorked2nd). So, it needs to either be within the selected date range for "DateWorked1st" AND/OR "DateWorked2nd". Is there a way to add this into the code, or will I break it? Is this even the best way to go about this?
I have a form where there are boxes where a user can select dates, and then if you click the button above it, it opens a report that has records that are between those two dates. Here is the code I'm using for that:
DoCmd.OpenReport "BENsReportCassieM", acViewReport, , "[DateWorked1st] >= #" & Forms!CassieMTotalsForm!BENsSDate & "# And [DateWorked1st] <= #" & Forms!CassieMTotalsForm!BENsEDate & "#"
The issue I'm having is, there is a second field I need it to look at as well, a second date (DateWorked2nd). So, it needs to either be within the selected date range for "DateWorked1st" AND/OR "DateWorked2nd". Is there a way to add this into the code, or will I break it? Is this even the best way to go about this?