trouble with dates-urgent

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a date field (lastUpdate) stored as a short date in
a table. I would like to compare that against today's
date. I have tried numerous ways, nothing works. Very
frustrated!!!

Thanks
 
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply
 
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If
 
function syntax error? try date()-1 rather than date-1.

hope this is it. if not you'll help from a VBA expert.
-----Original Message-----
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If

-----Original Message-----
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply


.
.
 
Have you tried stepping through the code to see what
values the date variables are giving you? You could hard
code the date variable(dDate=#9/22/04 for example)to see
what the code is actually doing.

Hope this helps
-----Original Message-----
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If

-----Original Message-----
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply


.
.
 
The date comparision works fine, I have checked it out
using control boxes. But, when labordate = Date()-1, it
still does not make the command invisible. I was thinking
that since I have been working with it for so loooog, I am
missing something that is glaringly visible to someone
else.

Thanks
-----Original Message-----
Have you tried stepping through the code to see what
values the date variables are giving you? You could hard
code the date variable(dDate=#9/22/04 for example)to see
what the code is actually doing.

Hope this helps
-----Original Message-----
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If

-----Original Message-----
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply


-----Original Message-----
I have a date field (lastUpdate) stored as a short date
in
a table. I would like to compare that against today's
date. I have tried numerous ways, nothing works. Very
frustrated!!!

Thanks
.

.
.
.
 
I have to go but I tried a quick test. It seems to be
skipping the first part of the conditional clause and
going to "enabled = true" Tomorrow I will try putting the
date diff value into a variable and checking to see if the
LaborDate field is actually involved in the calculation.

Hope this helps
-----Original Message-----
The date comparision works fine, I have checked it out
using control boxes. But, when labordate = Date()-1, it
still does not make the command invisible. I was thinking
that since I have been working with it for so loooog, I am
missing something that is glaringly visible to someone
else.

Thanks
-----Original Message-----
Have you tried stepping through the code to see what
values the date variables are giving you? You could hard
code the date variable(dDate=#9/22/04 for example)to see
what the code is actually doing.

Hope this helps
-----Original Message-----
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If


-----Original Message-----
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply


-----Original Message-----
I have a date field (lastUpdate) stored as a short date
in
a table. I would like to compare that against today's
date. I have tried numerous ways, nothing works. Very
frustrated!!!

Thanks
.

.

.
.
.
 
Try this code in the after update event of your labordate
text box. It cant go into the command button because the
button cannot be disabled while it has the focus

Private Sub txtLaborDate_AfterUpdate()
On Error GoTo Err_Click
Dim result As Integer

result = DateDiff("d", Date - 1, Me!txtLaborDate)

If result = 0 Then

Me![cmd4].Enabled = False
Me![cmd4].Visible = False
Else
Me![cmd4].Enabled = True
Me![cmd4].Visible = True
End If



' Screen.PreviousControl.SetFocus
' DoCmd.FindNext

Exit_Click:
Exit Sub

Err_Click:
MsgBox Err.Description
Resume Exit_Click
End Sub

Hope this helps
-----Original Message-----
The date comparision works fine, I have checked it out
using control boxes. But, when labordate = Date()-1, it
still does not make the command invisible. I was thinking
that since I have been working with it for so loooog, I am
missing something that is glaringly visible to someone
else.

Thanks
-----Original Message-----
Have you tried stepping through the code to see what
values the date variables are giving you? You could hard
code the date variable(dDate=#9/22/04 for example)to see
what the code is actually doing.

Hope this helps
-----Original Message-----
if equal, i would like to disable the command sutton
here's my code, labordate is 9/22/04

If DateDiff("d", Date - 1, Me![LaborDate]) = 0 Then
'If CDate(Date - 1) = CDate(Me![LaborDate]) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
Else
Me![Command1].Enabled = True
Me![Command1].Visible = True
End If


-----Original Message-----
More info please. Where are you trying to do the
comparison - in a query? What do you want the comparison
to do - calculate difference in days - flag if equal -
something else?

Waiting for reply


-----Original Message-----
I have a date field (lastUpdate) stored as a short date
in
a table. I would like to compare that against today's
date. I have tried numerous ways, nothing works. Very
frustrated!!!

Thanks
.

.

.
.
.
 
Back
Top