bill201
asked on
get a date value with dmin in access 2013
hi
i have in microsoft access a vba code that is checking (when i open the form) if there is a date in a date field that the date has been passed or it's the the today's date, and is so i show some msgbox. but for some reason i get every time when i open this form a msgbox with this value 00:00:00 (and there is no date like this in my date field), so why i get this date and how can i Bypass this problem
this is my code
i have in microsoft access a vba code that is checking (when i open the form) if there is a date in a date field that the date has been passed or it's the the today's date, and is so i show some msgbox. but for some reason i get every time when i open this form a msgbox with this value 00:00:00 (and there is no date like this in my date field), so why i get this date and how can i Bypass this problem
this is my code
On Error Resume Next
Dim d As Date
d = DMin("ReminderDate", "MecirahIncomeDetailsT", "ReminderDate<=#" & Date & "#")
MsgBox d
If d <= Date Then
Me.ReminderActiveCmd.Visible = True
MsgBox d
Else
Me.ReminderActiveCmd.Visible = False
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
fp:
thanks alot for your comment
in most records the reminderdate field is null (there is date value on the reminder field just if i need to remind something)
the solution isn't fixing the problem and i get still the date value 00:00:00
thanks alot for your comment
in most records the reminderdate field is null (there is date value on the reminder field just if i need to remind something)
the solution isn't fixing the problem and i get still the date value 00:00:00
BTW, a simpler way to write that logic is:
d = NZ(DMin("ReminderDate", "MecirahIncomeDetailsT", "ReminderDate<=#" & Date() & "#"),Date())
Jim.
d = NZ(DMin("ReminderDate", "MecirahIncomeDetailsT", "ReminderDate<=#" & Date() & "#"),Date())
Jim.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
Removing the 'On Error Resume Next' line may also help understand the issue as gustav succinctly summarised.
Removing the 'On Error Resume Next' line may also help understand the issue as gustav succinctly summarised.
ASKER
Many thanks to all of you, I was not here a good few hours, so I did not see your comments so I ignored until now, I am very sorry about this. Anyway thanks to you wonderful people I found the solution. And I split the points between you all, you deserve a lot more of these points, but it's what I have :)
this the code that i write and it's working excellent - A combination of some answers
this the code that i write and it's working excellent - A combination of some answers
d = DMin("ReminderDate", "MecirahIncomeDetailsT", "ReminderDate<=#" & Date & "# And Not(IsNull(ReminderDate))")
If Not IsNull(d) Then MsgBox d
:)
We're just glad you found a solution. No need to apologise at all.
Good luck with the rest of your project.
We're just glad you found a solution. No need to apologise at all.
Good luck with the rest of your project.
Are there any records in the table that do not have a value within the [ReminderDate] column?
The returned value of 00:00:00 seems to indicate that you do have at least one value that is blank/null.
Maybe you could change your code to take account of this, & to check that the DMin() function is working as you intended:
d = DMin("ReminderDate", "MecirahIncomeDetailsT", "ReminderDate<=#" & Date & "# And ReminderDate>#00:00:00#")
BFN,
fp.