Okay,
Here is the code. I'm am being very vulnerable here showing my coding skills or lack thereof.
It is updating the current record in an Act6.0 database.
This is the
vb.net version. The vb6 version is the same with syntax changes.
Sub Main()
Dim objApp As Object
Dim objViews As Object
Dim objContact As Object
Dim cAcceptanceDate As Integer = My.Settings.cAcceptanceDate
Dim cCategory As Integer = My.Settings.cCategory
Dim cDepartureDate As Integer = My.Settings.cDepartureDate
Dim cFAPReceived As Integer = My.Settings.cFAPReceived
Dim cFAPSent As Integer = My.Settings.cFAPSent
Dim cInactiveDate As Integer = My.Settings.cInactiveDate
Dim cInquiryDate As Integer = My.Settings.cInquiryDate
Dim cHoldDate As Integer = My.Settings.cHoldDate
Dim cPQReceived As Integer = My.Settings.cPQReceived
Dim cPQSent As Integer = My.Settings.cPQSent
Dim cPRStatus As Integer = My.Settings.cPRStatus
Dim cPRStatusNumber As Integer = My.Settings.cPRStatusNumber
Dim cPRCategory As Integer = CInt(My.Settings.cPRCategory)
Dim cMemberType As Integer = CInt(My.Settings.cMemberType)
'Short term dims
Dim cSTAcceptanceDate As Integer = CInt(My.Settings.cSTAcceptanceDate)
Dim cSTAppReceived As Integer = CInt(My.Settings.cSTAppReceived)
Dim cSTFinishDate As Integer = CInt(My.Settings.cSTFinishDate)
Dim cSTInactiveDate As Integer = CInt(My.Settings.cSTInactiveDate)
Dim cSTInquiryDate As Integer = CInt(My.Settings.cSTInquiryDate)
Dim cSTStartDate As Integer = CInt(My.Settings.cSTStartDate)
Dim cSTCategory As Integer = CInt(My.Settings.cSTCategory)
Dim strCategory As String = String.Empty
Dim strPRCategory As String = String.Empty
Dim strPRStatus As String = String.Empty
Dim strSTCategory As String = String.Empty
Dim intPRStatusNumber As Integer
Dim strMemberType As String = String.Empty
'Create a Views object.
objApp = CreateObject("ACTOLE.APPOBJECT")
objViews = objApp.Views
objContact = objViews.Create(1, "CV") 'Contact View
'Determine if FT or ST
strPRStatus = (CStr(objContact.getfield(cPRStatus)))
strCategory = CStr(objContact.getfield(cCategory))
strSTCategory = CStr(objContact.getfield(cSTCategory))
GetMemberType:
strMemberType = CStr(objContact.getfield(cMemberType))
'Get a member type if it is blank
'MessageBox.Show(strMemberType)
If (InStr("STFT-FT+", Left(strMemberType, 2), CompareMethod.Text).Equals(0)) Or strMemberType.Equals(String.Empty) Then
Dim strCheck As String = InputBox("If this person is a Short Termer " & _
"or a Fulltermer, please enter their Status (ST, FT+ or FT-) or enter 'n' for neither").ToUpper
If strCheck.Equals("N") Then
intPRStatusNumber = 0
'strCategory = String.Empty
strPRStatus = String.Empty
strPRCategory = String.Empty
GoTo UpDateFields
'Exit Sub
Else
If strCheck.ToUpper.Equals("ST") Then
strMemberType = "ST"
Else
If (InStr(1, "FT-FT+", strCheck.ToUpper, CompareMethod.Text).Equals(0)) Then
strMemberType = InputBox("What kind of member is this contact? 'FT+' or 'FT-'").ToUpper
End If
strMemberType = strCheck.ToUpper
End If
End If
objContact.setfield(cMemberType, strMemberType)
'Update the current record
objContact.update()
GoTo GetMemberType
End If
Select Case Left(strMemberType, 2)
Case "FT"
Try
If Not objContact.getfield(cDepartureDate).Equals("") Then
intPRStatusNumber = 7 'departure date
Else
If Not objContact.getfield(cAcceptanceDate).Equals("") Then
intPRStatusNumber = 6 'Acceptance date
Else
If Not objContact.getfield(cFAPReceived).Equals("") Then
intPRStatusNumber = 5 'FAP Received
Else
If Not objContact.getfield(cFAPSent).Equals("") Then
intPRStatusNumber = 4 'FAP Sent
Else
If Not objContact.getfield(cPQReceived).Equals("") Then
intPRStatusNumber = 3 'PQ Received
Else
If Not objContact.getfield(cPQSent).Equals("") Then
intPRStatusNumber = 2 'PQ Sent
Else
If Not objContact.getfield(cInquiryDate).Equals("") Then
intPRStatusNumber = 1 'Inq date
End If
End If
End If
End If
End If
End If
End If
Select Case intPRStatusNumber
Case 1
strPRStatus = "Inquirer"
strCategory = "Inquirer"
'strPRCategory = "Inquirer" & " - " & strPRStatus
Case 2
strPRStatus = "PQ Sent"
strCategory = "Inquirer"
'strPRCategory = "Inquirer" & " - " & strPRStatus
Case 3
strPRStatus = "PQ Recvd"
strCategory = "Candidate"
'strPRCategory = "Candidate" & " - " & strPRStatus
Case 4
strPRStatus = "FAP Sent"
strCategory = "Candidate"
'strPRCategory = "Candidate" & " - " & strPRStatus
Case 5
strPRStatus = "FAP Recvd"
strCategory = "Candidate"
'strPRCategory = "Candidate" & " - " & strPRStatus
Case 6
strPRStatus = "Accepted"
strCategory = "Appointee"
'strPRCategory = "Appointee" & " - " & strPRStatus
Case 7
strPRStatus = "To Field"
strCategory = "Missionary"
Case Else
strPRStatus = String.Empty
strCategory = String.Empty
MsgBox("Select a Category from the drop down list that " & _
"applies to this contact and please make sure at least the inquiry date is filled in.")
End Select
If Not objContact.getfield(cHoldDate).Equals("") Then
'MessageBox.Show("On Hold")
strPRStatus = "On Hold"
'strPRCategory = strCategory & " - " & strPRStatus
End If
If Not objContact.getfield(cInactiveDate).Equals("") Then
'MessageBox.Show("Inactive")
strPRStatus = "Inactive"
'strPRCategory = strCategory & " - " & strPRStatus
End If
strPRCategory = strCategory & " - " & strPRStatus
If Not objContact.getfield(cSTInquiryDate).Equals("") _
And objContact.getfield(cSTInactiveDate).Equals("") Then
MsgBox("On the Short Term tab, either enter the Inactive Date for this person " & vbCrLf & _
"or remove the Inquiry Date if it was entered by mistake " & vbCrLf & "or change the Member Type to ST.")
End If
GoTo updatefields
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, "Update " & strCategory & " Status")
End Try
'If the field changed is for a short termer...
Case "ST"
Try
If Not objContact.getfield(cSTInactiveDate).Equals("") Then
intPRStatusNumber = 106 ' Inactive
Else
If Not objContact.getfield(cSTFinishDate).Equals("") Then
intPRStatusNumber = 105 'Returned
Else
If Not objContact.getfield(cSTStartDate).Equals("") Then
intPRStatusNumber = 104 'On Field
Else
If Not objContact.getfield(cSTAcceptanceDate).Equals("") Then
intPRStatusNumber = 103 'Accepted
Else
If Not objContact.getfield(cSTAppReceived).Equals("") Then
intPRStatusNumber = 102 'Application Received
Else
If Not objContact.getfield(cSTInquiryDate).Equals("") Then
intPRStatusNumber = 101 'Inquiry
End If
End If
End If
End If
End If
End If
strCategory = "Short Term"
Select Case intPRStatusNumber
Case 101
strPRStatus = "Inquirer"
strSTCategory = "A:Inquiry"
Case 102
strPRStatus = "App Received"
strSTCategory = "D:Applying"
Case 103
strPRStatus = "Accepted"
strSTCategory = "B:Accepted"
Case 104
strPRStatus = "On Field"
strSTCategory = "A:On Field"
Case 105
strPRStatus = "Returned"
strSTCategory = "E:Returned"
Case 106
strPRStatus = "Inactive"
strSTCategory = "Inactive"
Case Else
strPRStatus = String.Empty
strSTCategory = String.Empty
MsgBox("Select a Category from the drop down list that applies to this contact.")
End Select
strPRCategory = strCategory & " - " & strPRStatus
If Not CStr(objContact.getfield(cInquiryDate)).Trim.Equal s(String.Empty) _
And CStr(objContact.getfield(cInactiveDate)).Trim.Equa ls("") Then
MsgBox("On the Dates tab, either enter the Inactive Date for this person " & vbCrLf & _
"or remove the Inquiry Date if it was entered by mistake " & vbCrLf & "or change the Member Type to FT.")
End If
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, "Update Short Term Status")
End Try
End Select
UpDateFields:
Try
'Update the fields
objContact.setfield(cPRCategory, strPRCategory)
objContact.setfield(cPRStatus, strMemberType)
objContact.setfield(cPRStatusNumber, intPRStatusNumber)
objContact.setfield(cCategory, strCategory)
objContact.setfield(cSTCategory, strSTCategory)
'Update the current record
objContact.update()
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, "Update Status Failed")
End Try
End Sub
Thanks for your suggestions.