Hey Guys,
Currently I'm using a code to find all records before a certain date.
I'm using
If LogDate < Date -5 Then
The problem with this is, Its only filtering by Day not month or year.
For example, It'll show all records like this
Shows 01/02/2011 - 07/02/2011
But not 08/02/2011 - 28/02/2011
Shows 01/03/2011 - 07/03/2011
But not 08/03/2011 - 31/03/2011
Any way I can set it to include the month/year in the date calculation so it excludes records from only the last five days?
Thanks in Advance.
9 2446
It sounds a bit odd to me. Is logDate a date/time variable? Can you include any code where you dim and/or manipulate it?
The code I'm using is this. - Public Function JobsDateFive(LogDate As String, ComDate As String, StatBox As String, TypeBox As String) As String
-
If LogDate < Date - 5 Then
-
If StatBox <> "Completed" Then
-
If StatBox <> "Cancelled" Then
-
If StatBox <> "Invoiced" Then
-
If StatBox <> "Resolved" Then
-
If StatBox <> "Attended" Then
-
If ((TypeBox = "CSTM01") Or (TypeBox = "CSTM02")) Then
-
JobsDateFive = "1"
-
Else
-
JobsDateFive = "0"
-
End If
-
End If
-
End If
-
End If
-
End If
-
End If
-
End If
-
End Function
-
Why are you passing your LogDate as a string? Its like comparing apples to elephants. You might get lucky and Access will guess the correct conversion from date->string->Date but it is bound to give you grief, and is most likely the cause of your current dilemma.
And you could simplify your code by including them in the same if statements, instead of nesting them.: - If StatBox <> "Completed" AND StatBox <> "Cancelled" AND StatBox <> "Invoiced" AND StatBox <> "Resolved" AND StatBox <> "Attended" Then
Hey Smiley,
Thanks for that... Was having a hard time but that totally fixed it. I've ordered a book on VBA as my new job seems to be requiring a lot of VBA coding.
Once again, Thanks
You are most welcome. Access can be quite forgiving in alot of cases, when it comes to using the correct variable type, but in my experience it will almost always cause you grief not to declare the variable type and think about using the correct variable type.
Okay, Ill keep that in mind!
Is there any Books/Documentation you recommend reading? I studied VBA at college but this was quite a long time ago!
The only VBA book I've read was "VBA for dummies", and then I've had alot of help from the guys and girls on this forum, as well as painstaking amounts of trial and error.
Well, I guess i'm on the right tracks.
I've just ordered Access VBA 2007 for Dummies, Think That'll help?
I found it to be a very good start. The rest you can learn as you go along. Ill be honest and admit though, that looking back at my first coding projects 2˝ year, I would do alot differently now, but thats experience, which you can't read your way into.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gerry Viator |
last post by:
Hi all,
I have a textbox were a time is typed in like: upto 4 numbers
1900
300
1000
1425
I would like as they type the text to show todays date plus the time they
|
by: Gary |
last post by:
Sorry to waste everyone's time with a query which is so simple, but as a new
user of Access I have created a client database and one of the fields is
"next contact due" as the name implies, this is...
|
by: Chuck |
last post by:
Using a macro to output a query to an Excel file.
Is there a way to automatically add todays date in the file spec?
As: C:\Access Data\ & todays date.xls
Chuck
....
|
by: rivka.howley |
last post by:
I wrote some code that creates a table with a date/time field at
15-minute intervals. Here's how I create and populate the table
With tblDataTemp
..Fields.Append .CreateField("CT_ID", dbLong)...
|
by: Vayse |
last post by:
In VB6, I would have used Date()
That no longer works.
How do I find todays date in VB.net?
|
by: Drum2001 |
last post by:
Hello, I am having isues with the following:
I have two forms, a MAIN FORM with a SUB FORM:
Within the MAIN FORM, I have an unbound textbox (Date Format) and a
command button. Onload, the...
|
by: kbaisch |
last post by:
I have this code set up but I know the 3rd line is wrong. Could someone please help me on the code for pulling all entries for todays date -90 days? I would really appreciate it and thanks for...
|
by: jonosborne |
last post by:
Hi guys, im a bit of a novice being thrown in at the deep end ! Using MS Access 97 i have a table with data that is updated once a day from an Excel spreadsheet. I need a way of identifying when data...
|
by: geethaandyou |
last post by:
I Need A C Program To Find The Date That Comes After N Days From Todays Date
|
by: phpmel |
last post by:
Hi guys,
I have an asp calendar control, text box, calendar icon, eraser icon all within an update panel. The calendar works fine, postbacks are handled without the flickering of the screen etc....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |