Good Afternoon,
I have a form which an associate needs to enter in various account criteria including dates. I have written the IF statement highlighted below and everything seemed to be working untill I tried to test the if statement which test whether or not the starts_on_pip_update date is less than the current date.
Here is the snippet of code that is not working. I am not getting any errors, it is just the "OR" statement does not seem to be firing. Do you think it is a parenthesis issue?
"Or Me.Starts_On_PIP_Update < Date"
I typed "HERE IS THE ISSUE" in the code below using the quote boxes. Is there a better way to point out the code I am trying to get you to look at going forward?
Thanks Guys!
I have a form which an associate needs to enter in various account criteria including dates. I have written the IF statement highlighted below and everything seemed to be working untill I tried to test the if statement which test whether or not the starts_on_pip_update date is less than the current date.
Here is the snippet of code that is not working. I am not getting any errors, it is just the "OR" statement does not seem to be firing. Do you think it is a parenthesis issue?
"Or Me.Starts_On_PIP_Update < Date"
I typed "HERE IS THE ISSUE" in the code below using the quote boxes. Is there a better way to point out the code I am trying to get you to look at going forward?
Thanks Guys!
PHP:
Private Sub Command96_Click()
Dim DB As DAO.Database
Set DB = CurrentDb
Dim rs As DAO.Recordset
Dim nulltest1 As Variant
Dim nulltest2 As Variant
Dim nulltest3 As Variant
Dim nulltest4 As Variant
Dim nulltest5 As Variant
Dim nulltest6 As Variant
Set nulltest1 = Me.Amount_PIP_Update
Set nulltest2 = Me.PPM_Code_PIP_Update
Set nulltest3 = Me.Pay_Date_PIP_Update
Set nulltest4 = Me.Pay_Month_PIP_Update
Set nulltest5 = Me.Starts_On_PIP_Update
Set nulltest6 = Me.Ends_On_PIP_Update
'tests to ensure starts on is populated
If Me.Starts_On_PIP_Update = "" Or IsNull(nulltest5) Or Me.Starts_On_PIP_Update = 0 Then
MsgBox "You have not submitted the PIP update information correctly. Please make sure that all of the below criteria is met." & vbNewLine & "" & vbNewLine & "- All fields have information populated EXCLUDING the 'Ends On' field." & vbNewLine & "-The 'Starts On' and 'Ends On' Date is either the 7th or 21st of the month." & vbNewLine & "-The 'Ends On' date is not less than the 'Starts On' date."
Else
'test passed, starts on is populated, now test to see if ends on is populated
If IsNull(nulltest6) = False And Me.Ends_On_PIP_Update <> "" And Me.Ends_On_PIP_Update <> 0 Then
'ends on is populated
If IsNull(nulltest1) Or Me.Amount_PIP_Update = 0 Or IsNull(nulltest2) Or Me.PPM_Code_PIP_Update = "" Or Me.PPM_Code_PIP_Update = 0 Or IsNull(nulltest3) Or Me.Pay_Date_PIP_Update = "" Or Me.Pay_Date_PIP_Update = 0 Or IsNull(nulltest4) Or Me.Pay_Month_PIP_Update = "" Or Me.Pay_Month_PIP_Update = 0 Or IsNull(nulltest5) Or Me.Starts_On_PIP_Update = "" Or Me.Starts_On_PIP_Update = 0 Or (Me.Starts_On_PIP_Update > Me.Ends_On_PIP_Update) Or Day(Me.Starts_On_PIP_Update) <> 21 And Day(Me.Starts_On_PIP_Update) <> 7 Or [quote]HERE IS THE ISSUE[/quote] ISSUE[/code]Me.Starts_On_PIP_Update < Date Or Day(Me.Ends_On_PIP_Update) <> 21 And Day(Me.Ends_On_PIP_Update) <> 7 Then
'variety of tests not passed
MsgBox "You have not submitted the PIP information correctly. Please make sure that all of the below criteria is met." & vbNewLine & "" & vbNewLine & "- All fields have information populated EXCLUDING the 'Ends On' field." & vbNewLine & "-The 'Starts On' and 'Ends On' Date is either the 7th or 21st of the month." & vbNewLine & "-The 'Starts On' date is not less than todays date." & vbNewLine & "-The 'Ends On' date is not less than the 'Starts On' date."
Else
'ACTION 'all tests passed successfully, proceed to command
Me.User_Name_PIP = Environ("username")
SQL = ""
SQL = SQL & " UPDATE Main_PIP_TBL "
SQL = SQL & " SET Main_PIP_TBL.Account = '" & Me.PIP_Account & "' "
SQL = SQL & " ,Main_PIP_TBL.Amount = '" & Me.Amount_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.PPM_Code = '" & Me.PPM_Code_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Pay_Date = '" & Me.Pay_Date_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Pay_Month = '" & Me.Pay_Month_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Starts_On = #" & Me.Starts_On_PIP_Update & "# "
SQL = SQL & " ,Main_PIP_TBL.Ends_On = #" & Me.Ends_On_PIP_Update & "# "
SQL = SQL & " ,Main_PIP_TBL.Funding = '" & Me.Funding_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Field_Changed = '" & Me.Field_Changes_pip_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Update_Date = now() "
SQL = SQL & " ,Main_PIP_TBL.Update_User = '" & Environ("Username") & "' "
SQL = SQL & " WHERE Main_PIP_TBL.Account = '" & Me.PIP_Account & "' "
SQL = SQL & " AND Main_PIP_TBL.autoNBR = " & Me.AutoNBR_PIP_Update & ";"
DB.Execute (SQL)
Me.Main_PIP_TBL_subform.Requery
MsgBox "Update Completed Successfully", vbInformation, "Update Complete"
Me.Field_Changes_pip_Update.BackColor = vbWhite
Me.Amount_PIP_Update.Value = ""
Me.PPM_Code_PIP_Update.Value = ""
Me.Pay_Date_PIP_Update.Value = ""
Me.Pay_Month_PIP_Update.Value = ""
Me.Starts_On_PIP_Update.Value = ""
Me.Ends_On_PIP_Update.Value = ""
Me.Funding_PIP_Update.Value = ""
Me.Field_Changes_pip_Update.Value = ""
Me.AutoNBR_PIP_Update = ""
SQL = " Select * From Main_PIP_TBL where account = '" & Me.PIP_Account & "';"
Me.Main_PIP_TBL_subform.Form.RecordSource = SQL
'end (variety of tests)
End If
'ends on is not populated
Else
'conduct variety of tests that do not involve ends on (it is not populated)
If IsNull(nulltest1) Or Me.Amount_PIP_Update = 0 Or IsNull(nulltest2) Or Me.PPM_Code_PIP_Update = "" Or Me.PPM_Code_PIP_Update = 0 Or IsNull(nulltest3) Or Me.Pay_Date_PIP_Update = "" Or Me.Pay_Date_PIP_Update = 0 Or IsNull(nulltest4) Or Me.Pay_Month_PIP_Update = "" Or Me.Pay_Month_PIP_Update = 0 Or IsNull(nulltest5) Or Me.Starts_On_PIP_Update = "" Or Me.Starts_On_PIP_Update = 0 Or Day(Me.Starts_On_PIP_Update) <> 21 And Day(Me.Starts_On_PIP_Update) <> 7 Then
'variety of tests (not involving ends on) NOT passed
MsgBox "You have not submitted the PIP update information correctly. Please make sure that all of the below criteria is met." & vbNewLine & "" & vbNewLine & "- All fields have information populated EXCLUDING the 'Ends On' field." & vbNewLine & "-The 'Starts On' and 'Ends On' Date is either the 7th or 21st of the month." & vbNewLine & "-The 'Starts on' date is not less than todays date." & vbNewLine & "-The 'Ends On' date is not less than the 'Starts On' date."
Else
'ACTION 'variety of tests passed successfully, proceed to command
Me.User_Name_PIP = Environ("username")
SQL = ""
SQL = SQL & " UPDATE Main_PIP_TBL "
SQL = SQL & " SET Main_PIP_TBL.Account = '" & Me.PIP_Account & "' "
SQL = SQL & " ,Main_PIP_TBL.Amount = '" & Me.Amount_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.PPM_Code = '" & Me.PPM_Code_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Pay_Date = '" & Me.Pay_Date_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Pay_Month = '" & Me.Pay_Month_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.ends_on = '' "
SQL = SQL & " ,Main_PIP_TBL.Starts_On = #" & Me.Starts_On_PIP_Update & "# "
SQL = SQL & " ,Main_PIP_TBL.Funding = '" & Me.Funding_PIP_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Field_Changed = '" & Me.Field_Changes_pip_Update & "' "
SQL = SQL & " ,Main_PIP_TBL.Update_Date = now() "
SQL = SQL & " ,Main_PIP_TBL.Update_User = '" & Environ("Username") & "' "
SQL = SQL & " WHERE Main_PIP_TBL.Account = '" & Me.PIP_Account & "' "
SQL = SQL & " AND Main_PIP_TBL.autoNBR = " & Me.AutoNBR_PIP_Update & ";"
DB.Execute (SQL)
Me.Main_PIP_TBL_subform.Requery
MsgBox "Update Completed Successfully", vbInformation, "Update Complete"
Me.Field_Changes_pip_Update.BackColor = vbWhite
Me.Amount_PIP_Update.Value = ""
Me.PPM_Code_PIP_Update.Value = ""
Me.Pay_Date_PIP_Update.Value = ""
Me.Pay_Month_PIP_Update.Value = ""
Me.Starts_On_PIP_Update.Value = ""
Me.Ends_On_PIP_Update.Value = ""
Me.Funding_PIP_Update.Value = ""
Me.Field_Changes_pip_Update.Value = ""
Me.AutoNBR_PIP_Update = ""
SQL = " Select * From Main_PIP_TBL where account = '" & Me.PIP_Account & "';"
Me.Main_PIP_TBL_subform.Form.RecordSource = SQL
'end (variety of tests)
End If
'end (is ends on populated?)
End If
'end (is starts on populated?)
End If
End Sub