Help with If statement

  • Thread starter Thread starter Raj
  • Start date Start date
R

Raj

I have a date field and when the user enters the date the
first If checks to see if the [Handoff Date] has been
entered this works great. The second If verifies if the
field [allissuescompdate] is blank
and if so it ask if the user wants to removed the date
from the field. This does not work.
the third IF ask if the user wants to enter the date it
work but if the user hit Cancel the date still enters.
I hope someone be kind and help me.
Thanks in Advance

If Len(Me.cbxhandoffdate.Value & "") = 0 Then
MsgBox "You must enter Hand-Off Date" & _
" before you can enter All Issues Resolved
Date.", vbExclamation, _
"Correction!"
Cancel = True
Me.cbxallissuecompdate.Undo
Else

If Len(Me.cbxallissuecompdate.Value & "") = "" Then
MsgBox " Are you stue you want to remove the" & _
" All Issues Resolved Date?"
Else
Exit Sub

If MsgBox("Are you sure you want to enter a Resolved
Date?", 65, "Close Circuit") = vbOK Then

Exit Sub

End If
End If
End If
 
I am not following what you are doing, but I do see one
problem:

If Len(Me.cbxallissuecompdate.Value & "") = "" Then

The len function returns a number. It should read:

If Len(Me.cbxallissuecompdate.Value & "") = 0 Then



Chris Nebinger
 
Chris,
Thank you for the reply. I posted the wrong code earlier
and I have solved my problem, but have now created
another. What I need to do is bypass my first if
statement if the user has not removed a date and start
with the next IF. what is happening is when the date is
entered it displays the message for the first IF and then
goes to the next. I am sure this might be easy but I am
teaching myself as I creating this database. I have
listed the new code below.
Thanks Raj

Private Sub cbxallissuecompdate_BeforeUpdate(Cancel As
Integer)
If IsNull(Me![cbxallissuecompdate]) Then

If MsgBox("You sure you want to removed the
resolved date?", 1, "Correction!") = vbCancel Then
Cancel = True
Me.cbxallissuecompdate.Undo
Exit Sub


ElseIf Len(Me.cbxhandoffdate.Value & "") = 0 Then
MsgBox "You must enter Hand-Off Date" & _
" before you can enter All Issues Resolved
Date.", vbExclamation, _
"Correction!"
Cancel = True
Me.cbxallissuecompdate.Undo

Else

If MsgBox("Are you sure you want to enter a Resolved
Date?", 1, "Close Circuit") = vbCancel Then
Cancel = True
Me.cbxallissuecompdate.Undo



End If
End If
End If
'End If
End Sub

-----Original Message-----
I am not following what you are doing, but I do see one
problem:

If Len(Me.cbxallissuecompdate.Value & "") = "" Then

The len function returns a number. It should read:

If Len(Me.cbxallissuecompdate.Value & "") = 0 Then



Chris Nebinger

-----Original Message-----
I have a date field and when the user enters the date the
first If checks to see if the [Handoff Date] has been
entered this works great. The second If verifies if the
field [allissuescompdate] is blank
and if so it ask if the user wants to removed the date
from the field. This does not work.
the third IF ask if the user wants to enter the date it
work but if the user hit Cancel the date still enters.
I hope someone be kind and help me.
Thanks in Advance

If Len(Me.cbxhandoffdate.Value & "") = 0 Then
MsgBox "You must enter Hand-Off Date" & _
" before you can enter All Issues Resolved
Date.", vbExclamation, _
"Correction!"
Cancel = True
Me.cbxallissuecompdate.Undo
Else

If Len(Me.cbxallissuecompdate.Value & "") = "" Then
MsgBox " Are you stue you want to remove the" & _
" All Issues Resolved Date?"
Else
Exit Sub

If MsgBox("Are you sure you want to enter a Resolved
Date?", 65, "Close Circuit") = vbOK Then

Exit Sub

End If
End If
End If


.
.
 
Back
Top