Strange date field problem

The current version of the SQLDate function on Allen Browne’s site is correct.

Use that instead of my addition/alteration.

Added link
http://allenbrowne.com/ser-36.html
 
Correction, no it’s not…still work in progress.
 
Sorry, getting a syntax error now

Code:
Private Function Buildfilter() As Variant
Dim varWhere As Variant

varWhere = Null

If Me.txtStartDate > "" Then
        varWhere = varWhere & "[DatRec] >= #" & SQLDate(Me.txtStartDate) & "#  AND "
    End If
        
If Me.txtEndDate > "" Then
        varWhere = varWhere & "[DatRec] <= #" & SQLDate(Me.txtEndDate) & "# AND "
    End If

It is reporting that there is a missing operator in the query expression '[DateRec] >= ##01/04/2010## AND [DateRec] <= ##30/04/2010##'

Does anybody actually read what is infront of them, especially code that they are going to use?
Read study and understand it?

SQLDate INSERTS # # around the formatted date.

To my mind this thread is chasing its tail, it should have stopped at post 8, with perhaps the addition of suggesting that a check for Null dates be incorporated in the users code at the beginning, no point in going any further if either date is Null, and as the properties of the input text boxes is short date (post 3) then that can be the only problem.


Brian
 
Last edited:
Does anybody actually read what is infront of them, especially code that they are going to use?
Read study and understand it?

SQLDate INSERTS # # around the formatted date.

To my mind this thread is chasing its tail, it should have stopped at post 8, with perhaps the addition of suggesting that a check for Null dates be incorporated in the users code at the beginning, no point in going any further if either date is Null, and as the properties of the input text boxes is short date (post 3) then that can be the only problem.


Brian

Forgive me Brian, but not all of us are VBA Guru's, some of us are just starting out, the last thing we need is for the so called experts shouting us down because we dont understand what they are conveying to us. I dish out a lot of advice on other forums in regards to hardware but I would never reply in the manner that you did. This is the kind of thing that puts the novices off from asking questions.

Chris, cheers bud, got it working at 2am last night;)
 
I didn't shout anybody down, just got frustrated that what was infront of us was not being studied. I assume that you are an intelligent person and therefore can understand the code if you study it, if not you will ask specifics about the code, not blindly use it.

Brian
 
I didn't shout anybody down, just got frustrated that what was infront of us was not being studied. I assume that you are an intelligent person and therefore can understand the code if you study it, if not you will ask specifics about the code, not blindly use it.

Brian


fair enough Brian, but VBA is new to me, SQL is not but I am more familiar with ANSI SQL than the flavour in Access. My experience of VBA is limited and have only really been on a 2 day crash course and read a book or 2.

This code is the first bit of adventurous code I have done, so I apologise If I seem a little slow in picking up what you guys are saying.
 

Users who are viewing this thread

Back
Top Bottom