I am having an error when this filter is applied: - Private Sub ThisWeekFilter_Click()
-
Me.Filter = "(Year(ProjectScheduleT.DateStart)=Year(Date()) And DatePart("ww",ProjectScheduleT.DateStart,0)=DatePart("ww",Date(),0))"
-
Me.FilterOn = True
For some reason it works fine when I apply it directly from the filter tool on the Ribbon but when I try to use it in VBA it highlight "ww" as an error. Does anyone know why?
Thanks
Try replacing the Double Quotes (") with Singles (') within the DatePart() Function: - Me.Filter = "(Year(ProjectScheduleT.DateStart)=Year(Date()) And " & _
-
"DatePart('ww',ProjectScheduleT.DateStart,0) = DatePart('ww',Date(),0))"
-
Me.FilterOn = True
8 3502
Try replacing the Double Quotes (") with Singles (') within the DatePart() Function: - Me.Filter = "(Year(ProjectScheduleT.DateStart)=Year(Date()) And " & _
-
"DatePart('ww',ProjectScheduleT.DateStart,0) = DatePart('ww',Date(),0))"
-
Me.FilterOn = True
NeoPa 32,556
Expert Mod 16PB
Try following this advice always. It is worth doing even before you get to thinking about asking any questions. In this case the compiler would have found and reported your problem without the need for a question. When posting any code on here please :- Ensure you have Option Explicit set (See Require Variable Declaration).
- Try to compile it. If it doesn't compile for any reason please explain that clearly - including the error message and which line of your code it appears on. Compilation is done from the Visual Basic Editor menu - Debug \ Compile Project (Where Project is the actual name of your project).
- Copy your code (using the Clipboard - Cut / Copy / Paste) from your project directly into your post. Typing in code is not appreciated as it is likely to introduce typos which cause members to waste their time unnecessarily.
- Ensure that the code in your post is enveloped within CODE tags. The hash (#) button in the posting page helps with this. Simply select your code and click on the hash button to have it enveloped automatically.
If all these points are covered then all members will be better able to understand, and therefore attempt to answer, your question. NeoPa 32,556
Expert Mod 16PB
I suppose I should also highlight a problem the compiler won't find for you : - Me.Filter = "(Year(ProjectScheduleT.DateStart)=Year(Date()) And DatePart("ww",ProjectScheduleT.DateStart,0)=DatePart("ww",Date(),0))"
This line makes little sense as I see it, as the second must always be true if the first is. If two dates are equal, then the week values of those dates cannot help but be equal also.
Thanks Adezii, the changing of the quotes " to ' did the trick. Much appreciated.
NEOPA: I always wondered about this "Option explicit" and "Option Compare Database" line at the top. I understand what "Option Explicit" means, but what does"Compare database" line about?
NeoPa 32,556
Expert Mod 16PB
specifies how comparisons are made in the code. Check the Help system for full details, but basically it determines how strings should be compared. Is the case of the characters to be considered or ignored. The Database setting indicates to use the setting defined in the databse options, but you can choose to take control and set it explicitly if you prefer.
I appreciate the feedback, thanks a million. You guys are by far the best bunch online.
NeoPa 32,556
Expert Mod 16PB
We're always glad to help when we can :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robin Cull |
last post by:
Imagine I have a dict looking something like this:
myDict = {"key 1": , "key
2": , "key 3": ,
"key 4": }
That is, a set of keys which have a variable length list of associated
values after...
|
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...
|
by: dick |
last post by:
I am just trying to print/report the results of a "filter by
selection" which is done by right-clicking a form, filling in values,
and "applying the filter."
I have searched the newsgroups, and...
|
by: Keith |
last post by:
A2003, XP Pro.
I'm in the middle of designing a form to act as a custom filter, like a
very basic 'filter by form'. It has two sets of combos, those on the
left are to choose the field name(s)...
|
by: cefrancke |
last post by:
I have a form (no underlying record set) that has two separate
sub-forms on it.
Each sub-form has data from two different tables.
Above each sub-form there is one unbound combo box with a SQL...
|
by: AAJ |
last post by:
I know this sounds nuts, but how do I remove the following filter from a
Object Datasource that looks at my business layer...
ODSDefaultUserProfiles.FilterExpression = "AllowedWebPage = '" +...
|
by: dee |
last post by:
I'd like to filter by the following criteria:
left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767
I have no idea how to do this. Appreciate help.
|
by: scatterbrain |
last post by:
I'm trying to create a popup form so that my peers have and easy way to filter information by 4 categories: Presenter, Evaluator, Date, or Topic. All this information is stored in my Data table and I...
|
by: Soulspike |
last post by:
Form name to filter = frmSortFor
Filter based on list box from frmTest= lstSortFor
Form containing list box = frmTest
Field (CompCodes) data format = "PM SM TS EW WA"
I have a database that I...
|
by: Twayne |
last post by:
Hi,
I've been playing with ' if(!filter_var($email, FILTER_VALIDATE_EMAIL))
'
on my server and it seems to be working 100%. Pretty handy.
Any ideas where I could find a summary of the e-mail...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |