By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,675 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Filter SubForm by changing query criteria to a specific day of week

P: 52
Hey guys. I have a form and subfrom. i have a button on the main form that when clicked sets the subform recorsource using a query in VBA. what i need is to find any records whos StartDate is either Saturday or Sunday. i was able to get another button to find records eqaul to Today using a variable, the code is pasted below - i cant figure out how to find those that equal Saturday or Sunday on the fly. Thanks guys!

Private Sub cmdToday_Click()

Dim sSQL As String
Dim viewToday
viewToday = Format(Now(), "mm/dd/yyyy")

sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = #" & viewToday & "#;"
Me![ViewCasesSubform].Form.RecordSource = sSQL

End Sub
Dec 13 '07 #1
Share this Question
Share on Google+
2 Replies


puppydogbuddy
Expert 100+
P: 1,923
Hey guys. I have a form and subfrom. i have a button on the main form that when clicked sets the subform recorsource using a query in VBA. what i need is to find any records whos StartDate is either Saturday or Sunday. i was able to get another button to find records eqaul to Today using a variable, the code is pasted below - i cant figure out how to find those that equal Saturday or Sunday on the fly. Thanks guys!

Private Sub cmdToday_Click()

Dim sSQL As String
Dim viewToday
viewToday = Format(Now(), "mm/dd/yyyy")

sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = #" & viewToday & "#;"
Me![ViewCasesSubform].Form.RecordSource = sSQL

End Sub
Try this:

sSQL = "SELECT * FROM QueryCases WHERE Weekday(QueryCases.StartDate) = 1 OR Weekday(QueryCases.StartDate) = 7;"
Dec 13 '07 #2

P: 52
Boy did that work, thank you very much - you saved the day around here.
Dec 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.