Form Date Field Less than Form Date Field 2 + 30 days (1 Viewer)

Lochwood

Registered User.
Local time
Today, 14:11
Joined
Jun 7, 2017
Messages
130
I have 2 date fields in a subform and code that if [Date_Field1] < [Date_Field2] it displays a hidden button . this works but i would only like the button to show if [Date_Field1] < [date_Field2] +30 days. Cant get the code to work by adding +30. where am i going wrong?

Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:11
Joined
Oct 29, 2018
Messages
21,528
Hi. Can you show us your code please?
 

Lochwood

Registered User.
Local time
Today, 14:11
Joined
Jun 7, 2017
Messages
130
Hi. Can you show us your code please?

If [Last_date] < ([Due_Date_Field] +30) Then
Me.Update_DD_Button.Visible = True

End If
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:11
Joined
Oct 29, 2018
Messages
21,528
If [Last_date] < ([Due_Date_Field] +30) Then
Me.Update_DD_Button.Visible = True

End If
Thanks. What happens if you change that to this?
Code:
 If [Last_date] < DateAdd("d",30,[Due_Date_Field]) Then
    Me.Update_DD_Button.Visible = True
End If
 

Lochwood

Registered User.
Local time
Today, 14:11
Joined
Jun 7, 2017
Messages
130
Thanks. What happens if you change that to this?
Code:
 If [Last_date] < DateAdd("d",30,[Due_Date_Field]) Then
    Me.Update_DD_Button.Visible = True
End If

Still the same. regardless of what date i put in.. it shows the button.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:11
Joined
Oct 29, 2018
Messages
21,528
Still the same. regardless of what date i put in.. it shows the button.
Okay, I have a feeling we're not talking about actual dates here. Can you post some sample data or screenshots? Where are those dates coming from?
 

Lochwood

Registered User.
Local time
Today, 14:11
Joined
Jun 7, 2017
Messages
130
Okay, I have a feeling we're not talking about actual dates here. Can you post some sample data or screenshots? Where are those dates coming from?


Cant really send you that. the date fields are Medium Date format and are actual fields in the table. if i take out the + 30 it works
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:11
Joined
Oct 29, 2018
Messages
21,528
Cant really send you that. the date fields are Medium Date format and are actual fields in the table. if i take out the + 30 it works
No screenshots either? Hmm, can you type those dates in your post? For example, does this work?

Code:
If "9/22/2020" < "9/23/2020" Then
    Me.Update_DD_Button.Visible = True
End If
 

Isaac

Lifelong Learner
Local time
Today, 14:11
Joined
Mar 14, 2017
Messages
8,850
You need an ELSE statement that makes it visible=false

if condition then
button=true
else
button=false
end if
 

Users who are viewing this thread

Top Bottom