What is wrong with this code? (1 Viewer)

ccguillermo

New member
Local time
Yesterday, 21:06
Joined
Nov 18, 2013
Messages
9
Hi
I creae this code to update one field but it does not work in the way should be some body can help me what is wrong with this code. I get the same Answers "No Date In Boths Fields"
when I enter the information to my form

'this process update the Visibility Status
'If Date_Submitted_To_CMS = "" and Date_CMS_Approved =""

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.Date_Submitted_To_CMS0)) Or (IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "Not Processed"
MsgBox "No Date In Boths Fields"
ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) Or (IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "In Process"
MsgBox "There is date in the first but not in the second field"
ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) Or (Not IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "Complete"
MsgBox "There is date in the first in the second too"
Else
Cancel = True
Me.Visibility_Status.SetFocus
MsgBox "me sacaron"
End If
End Sub

attached do you find my table an my form

Thank you very mcuh for you help

Calucho:banghead:
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 05:06
Joined
Feb 19, 2013
Messages
16,663
Your code is unreadable please use the code tabs - use the advanced editor, highlight the text and click the # button.

Also ensure that you have your code suitably inset

Please also clarify what you mean by 'it does not work' - give examples of the input and what you expect to see
 

ccguillermo

New member
Local time
Yesterday, 21:06
Joined
Nov 18, 2013
Messages
9
hI


'this process update the Visibility Status
'If Date_Submitted_To_CMS = "" and Date_CMS_Approved =""

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.Date_Submitted_To_CMS0)) Or (IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "Not Processed"

MsgBox "No Date In Boths Fields"

ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) Or (IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "In Process"

MsgBox "There is date in the first but not in the second field"

ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) Or (Not IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "Complete"

MsgBox "There is date in the first in the second too"

Else
Cancel = True
Me.Visibility_Status.SetFocus
MsgBox "Out of base"
End If
End Sub
 

WayneRyan

AWF VIP
Local time
Today, 05:06
Joined
Nov 19, 2002
Messages
7,122
cc,

I think you just have to change your "Ors" to "Ands".

Code:
(code) <-- Change these to square brackets

'this process update the Visibility Status
'If Date_Submitted_To_CMS = "" and Date_CMS_Approved =""

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.Date_Submitted_To_CMS0)) [SIZE="2"][B]AND [/B][/SIZE](IsNull(Me.Date_CMS_Approved)) Then
   Me.Visibility_Status.Value = "Not Processed"
   MsgBox "No Date In Boths Fields"
ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) [B][SIZE="2"]AND [/SIZE][/B](IsNull(Me.Date_CMS_Approved)) Then
Me.Visibility_Status.Value = "In Process"  
   MsgBox "There is date in the first but not in the second field"
ElseIf (Not IsNull(Me.Date_Submitted_To_CMS)) [B][SIZE="2"]AND [/SIZE][/B](Not IsNull(Me.Date_CMS_Approved)) Then
   Me.Visibility_Status.Value = "Complete"
MsgBox "There is date in the first in the second too"
Else
   Cancel = True
   Me.Visibility_Status.SetFocus
   MsgBox "Out of base"
End If
End Sub 
(/code)

To make your code look a little better, use code tags by changing "(code)" and
"(/code)" as shown above.

Wayne
 

ccguillermo

New member
Local time
Yesterday, 21:06
Joined
Nov 18, 2013
Messages
9
Hi Wayne,

Thank yoy very mcuh for you help; it's works good.

Have a very nice week..

Carlos:)
 

Users who are viewing this thread

Top Bottom