Here is the Code
Public Function Project_Status_Tracking() As Boolean
Dim Assigned_Project_Status As String
Dim DB_Project_Status As String
Dim SSQL As String
Dim SSQL1 As String
Dim Project_ID As Integer
Dim RecordCount1 As Integer
Dim RecordCount2 As Integer
Project_ID = Oppt_ID_Text
Assigned_Project_Status = Status
SSQL = "Select Status from Sales_Pipeline_Current where Oppt_Id =" & Project_ID & ";"
SSQL1 = "Select Oppt_Id from Sales_Pipeline_Current where Oppt_Id = " & Project_ID & ";"
Set db = CurrentDb()
Set rs1 = db.OpenRecordSet(SSQL)
Set rs2 = db.OpenRecordSet(SSQL1)
RecordCount1 = rs1.RecordCount
RecordCount2 = rs2.RecordCount
If RecordCount1 = 0 And RecordCount2 = 0 Then
'New Record
Project_Status_Tracking = True
ElseIf RecordCount1 > 0 And RecordCount2 > 0 Then
DB_Project_Status = rs1.fields("Status")
If Assigned_Project_Status = DB_Project_Status Then
'Not Changing Project Status
Project_Status_Tracking = True
Else
Select Case Assigned_Project_Status
Case "Pre"
If Proposal_Text = "No" Then
MsgBox "Error Setting Project Status to PRE: Project Proposal Missing"
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Case "Post"
If DB_Project_Status = "Pre-Pre" Or DB_Project_Status = "Pre" Then
If Proposal_Text = "No" Then
MsgBox "Error Setting Project Status to POST: Project Proposal Missing"
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to Post: Project Proposal Missing"
Project_Status_Tracking = Flase
End If
Case "Verbal"
If DB_Project_Status = "Post" Then
If Proposal_Text = "No" Then
MsgBox "Error Setting Project Status to Verbal: Project Proposal Missing"
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to Verbal: Wrong Porject Flow"
Project_Status_Tracking = False
End If
Case "Won"
If DB_Project_Status = "Post" Or DB_Project_Status = "Verbal" Then
If Folder_Text = "No" Or SOW_Text = "No" Then
MsgBox "Error Setting Project Status to WON: SOW or Intraspect Folder Missing"
'Exit Function
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to WON: Wrong Porject Flow"
'Exit Function
Project_Status_Tracking = False
End If
Case "WIP"
If DB_Project_Status = "Won" Then
If Folder_Text = "No" Or SOW_Text = "No" Then
MsgBox "Error Setting Project Status to WON: SOW or Intraspect Folder Missing"
'Exit Function
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to WIP: Wrong Porject Flow"
'Exit Function
Project_Status_Tracking = False
End If
Case "Complete"
If DB_Project_Status = "WIP" Then
If Delieverable_Text = "No" Or Quals_Text = "No" Then
MsgBox "Error Setting Project Status to Complete: Deliverables Or Quals Missing "
'Exit Function
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to Complete: Wrong Porject Flow"
'Exit Function
Project_Status_Tracking = False
End If
Case "Close"
If DB_Project_Status = "WIP" Then
If Delieverable_Text = "No" Or Quals_Text = "No" Then
MsgBox "Error Setting Project Status to Complete: Deliverables Or Quals Missing "
'Exit Function
Project_Status_Tracking = False
Else
Project_Status_Tracking = True
End If
Else
MsgBox "Error Setting Project Status to Close: Wrong Porject Flow"
'Exit Function
Project_Status_Tracking = False
End If
End Select
End If
End If
Private Function Check_Data() As Boolean
If IsNull(Oppt_ID_Text) Then
MsgBox "Project Id not assigned "
Check_Data = False
Exit Function
ElseIf IsNull(Status) Then
MsgBox "Please Assign Project Status"
Check_Data = False
Exit Function
ElseIf IsNull(Project_Name) Then
MsgBox "Please Assign Project Name"
Check_Data = False
Exit Function
Else
Check_Data = True
End If
End Function
Thanks in Advance...
