Well, to address the specific issue you posted about, I'm going to assume
that Void_Date
represents the membership expiration date. If that is the case, then you
have the date
values in the expression backwards. It should be;
DaysRemaining: DateDiff("d", Date(), [Void_Date])
However, there are other issues that you should consider, or at least be
aware of.
First, if all memberships expire 1 year from the Start_Date, then you
shouldn't have
the Void_Date field in your table at all. It should be a calculated field
in
a query as
I explained in a previous thread.
Second, it would appear you have several other unnecessary fields in your
table as well.
You have the following fields as Foreign Keys;
Badge_ID = FK
DaysHours_ID = FK
Security_ID = FK
Contact_ID = FK
Company_ID = FK
which means that, presumably, you have tables for each of those entities.
So, the
following fields should already exist in those tables;
Company_Name = Text
Contact_Name = Text
Days_Hours = Text
Badge_Type = Text
You don't need to (and shouldn't) redundantly store these values in your
Main table. You
simply retrieve the values from their respective tables based on the FK
value that exists
in the Main table. You do this through the use of queries or calculated
controls on forms
or reports.
Additionally, if the Full_Name field represents a persons name, it should
be
separated into
FirstName and LastName, not stored in one field.
_________
Sean Bailey
Beetle,
The function I am using in my query is:
DaysRemaining: (DateDiff("d",[Void_Date],Date()))
Here's my table (Main) structure:
MainID = PK
Badge_ID = FK
DaysHours_ID = FK
Security_ID = FK
Contact_ID = FK
Company_ID = FK
Full_Name = Text
Company_Name = Text
Contact_Name = Text
Days_Hours = Text
Start_Date = Date/Time
Void_Date = Date/Time
Badge_Type = Text
Thanks for hanging in there with me Beetle.
KP
:
The second case would handle all dates beyond current year
(2010...) where DateDiff returns negative numbers.
I don't know what you are doing, but the only way that would
happen is if you put the later (2010) date first. This;
DateDiff("d", #6/8/2009#, #6/8/2010#)
will return 365
This;
DateDiff("d", #6/8/2010#, #6/8/2009#)
will return -365
DateDiff is a VERY SIMPLE function, so I don't know why you are
having so much trouble with it.
Why don't you post your table structure (ie - the table where the
membership start date field exists), and maybe we can go form there.
The only value you should need to store is the membership
start / renewal date. Everything beyond that is a simple calculation.
--
_________
Sean Bailey
:
John, Beetle,
After looking at my scenario further I have concluded that a good
approach
might be to use two different Select Case statements. The first
Case
would
handle all dates in the current year 2009 where DateDiff returns
positive
numbers. The second case would handle all dates beyond current year
(2010...) where DateDiff returns negative numbers. With this
principle
in
mind, the Case tests might look something like the following:
If Me.txtDaysRemaining >= 0 then
Select Case Me.txtDaysRemaining
Case 0 To 7
Me.lblVoid.Caption = "Membership Will Expire In " _
& Me.txtDaysRemaining & " Day(s)"
Case Is = 0
Call MembershipExpired
End Select
Elseif Me.txtDaysRemaining <= 0 then
Select Case Me.txtDaysRemaining
Case -7 To 0
Me.lblVoid.Caption = "Membership Will Expire In " _
& ABS(Me.txtDaysRemaining) & " Day(s)"
Case Is = 0
Call MembershipExpired
End Select
End If
So if the above scenario worked, then I would only need to figure
out
how to
deal with memberships once they go beyond the expiration date.
Can't
figure
out how to do that though without having a special field in my table
that
marks the expired membership. I know Beetle would not agree to
having
such a
field in my table but I see no other way around it since I rely on
DaysRemaining being zero, and staying zero when a membership
expires.
-KP
:
On Fri, 5 Jun 2009 18:56:01 -0700, Keypad
<
[email protected]>
wrote:
John,
That's a good question. Guess I would have to test it out and
see
what the
results look like. First off though, were I to use the approach
you
submitted as an interpretation of what MSDN say's about DateDiff
I
foresee
the need to have to use other functions to slice and dice the
dates
to get
the ##/## or #/# part of the date before I could have anything
useful. The
second task would be how to use it in a query.
Seriously:
You are making this a LOT HARDER than it actually is.
If you have a due date and you want to see how many days it is in
the
future,
you don't need to slice and dice ANYTHING.
Maybe take a day off, get some rest, and come back and reread this
thread. It
is *simpler than you are making it*.