Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

MS Access VBA Need help with statement to control another field

Why doesn't this code work?

 If IsDate(Me.AendDate) = True Then -----------------This part works fine.
        Me.Status = "Completed"
    Else
If IsDate(Me.AendDate) = False Then -----------------This part doesn't work. If date is deleted,
        Me.Status = "Working"                      I want the status field to change to "Working".
       End If
    End If
End Sub
0
DJPr0
Asked:
DJPr0
  • 3
  • 3
  • 2
  • +1
1 Solution
 
nickinthoozCommented:
take out

If IsDate(Me.AendDate) = False Then

You're using else and a boolean so it can only be true or false, if it's not true then it's got to be false?
 If IsDate(Me.AendDate) = True
        Me.Status = "Completed"
    Else
        Me.Status = "Working"                
       End If

Open in new window

0
 
DJPr0Author Commented:
Only the first part works (Completed)

Does the After Update kick in when the date is deleted?

The "Completed" doesn't change to "Working" when the date is deleted.
0
 
Rey Obrero (Capricorn1)Commented:
try something like this

 If IsDate(Me.AendDate) = True and me.AendDate & ""<>"" then
        Me.Status = "Completed"
    Else
        Me.Status = "Working"                
       End If
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
nickinthoozCommented:
if you delete the date, you need to put the code somewhere it can check, like the on change event or after the focus to the date field is lost.
0
 
DJPr0Author Commented:
Same problem - Works only for "Completed".
0
 
Rey Obrero (Capricorn1)Commented:
DJPro
where did you placed the codes ?

and when responding, pls, mention the expert to whom you are responding.
0
 
jerryb30Commented:
Private Sub aenddate_AfterUpdate()
If IsDate(Me.aenddate) Then
Me.status2 = "Completed"
Else
Me.status2 = "working"
End If
End Sub

works for me after leaving aenddate after a deletion.
0
 
nickinthoozCommented:
what about

 If IsDate(Me.AendDate) = True
        Me.Status = "Completed"
    Elseif  isnull(me.[fieldname]) then
        Me.Status = "Working"                
       End If

Open in new window


change your fieldname to whatever your fieldname is.
0
 
DJPr0Author Commented:
I had some conflicting code that ran above this statement.

Sorry for the confusion.

The first post works fine.

Thanks!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now