473,698 Members | 2,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

52 New Member
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.Star tDate = #" & viewToday & "#;"
Me![ViewCasesSubfor m].Form.RecordSou rce = sSQL

End Sub
Dec 13 '07 #1
2 1779
puppydogbuddy
1,923 Recognized Expert Top Contributor
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.Star tDate = #" & viewToday & "#;"
Me![ViewCasesSubfor m].Form.RecordSou rce = sSQL

End Sub
Try this:

sSQL = "SELECT * FROM QueryCases WHERE Weekday(QueryCa ses.StartDate) = 1 OR Weekday(QueryCa ses.StartDate) = 7;"
Dec 13 '07 #2
darnnnel
52 New Member
Boy did that work, thank you very much - you saved the day around here.
Dec 13 '07 #3

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

Similar topics

1
7848
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside from queries. Let me just add that Allen Browne excellent article about this subject may not apply to this scenario on an elementary level. (Here's the link to the article; Filter a Form on a Field in a Subform -...
2
9797
by: Andante.in.Blue | last post by:
Hi everyone! I was wondering if there is a away to use Access 97's build in filter-by-form function but restrict its effect to just the subform. I have a parent form that shows the major divisions of the company, and a subform that is linked so that it displays all the jobs within the division in the parent form. I also want the ability to filter the subform, so the users can pick out a bunch of common jobs easily. I did this using a...
1
2234
by: Colin | last post by:
I created a macro that starts a filter on a query. The criteria in the query is: Like & "*" The macro is initiated by pressing a command button on the form. This works fine. However, when this form becomes an unbound subform of another main form, I'm prompted twice for the value of the filter (i.e. the group name to enter). How can I stop the double prompt when my form is used
1
3094
by: New2Access | last post by:
I posted this yesterday but perhaps I wasn't clear enough. I have a table called History with 4 fields "Week" "Employee" "Project" and "Hours" Each of those fields (except Hours) are based on seperate tables with a 1 to many relationship to the History table. I have a form called WeeklyInput for data entry into the History table. There is a combobox for "Weeks" which defaults to the current week. There is a textbox for "Employee"...
3
11961
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one subform..... This MSDN article however makes it sound as simple as clicking "Filter by Form", entering the search criterial in the form and/or it's subforms, then just clicking "Apply Filter"...... ...
0
346
by: bcreighton | last post by:
I have created a bound subform on an unbound masterform linked together with a common field (A store's identification number) using an unbound combobox on the masterform and an invisible field on the subquery, which filters for a particular store. The subform is in continuous mode. So, what you see when you select a store is a list of all the items that that have not been billed for. There is a simple yes no field that filters out all...
14
11462
by: Kurt | last post by:
I have an unbound main form with an unbound subform. frmProjects fsubProjectList Using combo boxes, the user can select several search criteria on frmProjects and then click a command button. The command button passes the criteria as a string to a query. A subform, which is based on this query, shows the results of the search.
2
4203
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my reasons ). The ssbform's query has a criteria for forms!masterform!Keyfield. This works fine on open. I have an options group with two options - True or All. Selecting True adds a filter to the subform's fitler property "Billed = True". That...
5
3331
Jerry911
by: Jerry911 | last post by:
Hi, I have a query that I use to export data to a spreadsheet. The query itself works fine and I can manually edit the query to supply filtered information. What I would like to do is use a form that has several filter options so I do not have to modify my query every time I run it. I have a form with a list box to define one of the filters and I can make it work with that specific filter using the DoCmd.ApplyFilter function. I want/need to...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.