This example teaches you how to write a script to start a new job, assign the next number, save the job, then edit it. We'll also check:
If your client works with Job Costing this script provides a way to generate the next (numeric) Job code.
(Alt+F1) to start recording.F7 to step back to the last numeric code.F4) to insert a new job.Alt+F1)to stop recording.Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find("ASHENG REFIT")
frmJCJob1.Find("700010")
frmJCJob1.Insert
Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find(":")
frmJCJob1.Find("1010")
frmJCJob1.Insert
Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find(":")
frmJCJob1.Prev
frmJCJob1.Insert
Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
frmJCJob1.Insert
'Add a new job and calculate the next job number
Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
frmJCJob1.Insert
frmJCJob1.JobCode = MyJob
Save this with the file name StartNewJob.pfs. Run the code.
'Add a new job and calculate the next job number
Dim frmJCJob1 as Object
frmJCJob1 = CreateObject("Accredo.JCJobForm")
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
frmJCJob1.Insert
frmJCJob1.JobCode = MyJob
frmJCJob1.Save
frmJCJob1.Edit
'Add a new job and calculate the next job number
Dim frmJCJob1 as Object
frmJCJob1 = GetActiveObject
If IsNull(frmJCJob1) or frmJCJob1.ClassName <> "JCJobForm" Then ' Can we reuse the current form
frmJCJob1 = CreateObject("Accredo.JCJobForm") ' If not open a new one
End If
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
frmJCJob1.Insert
frmJCJob1.JobCode = MyJob
frmJCJob1.Save
frmJCJob1.Edit
'Add a new job and calculate the next job number
Dim frmJCJob1 as Object
frmJCJob1 = GetActiveObject
If IsNull(frmJCJob1) or frmJCJob1.ClassName <> "JCJobForm" Then ' Can we reuse the current form
frmJCJob1 = CreateObject("Accredo.JCJobForm") ' If not open a new one
ElseIf frmJCJob1.ClassName = "JCJobForm" And frmJCJob1.Editing Then
Abort("Current Job is being edited. Insert cancelled. Please save changes and re-try.")
End If
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
frmJCJob1.Insert
frmJCJob1.JobCode = MyJob
frmJCJob1.Save
frmJCJob1.Edit
'Add a new job and calculate the next job number
Dim frmJCJob1 as Object
frmJCJob1 = GetActiveObject
If IsNull(frmJCJob1) or frmJCJob1.ClassName <> "JCJobForm" Then ' Can we reuse the current form
frmJCJob1 = CreateObject("Accredo.JCJobForm") ' If not open a new one
ElseIf frmJCJob1.ClassName = "JCJobForm" And frmJCJob1.Editing Then
Abort("Current Job is being edited. Insert cancelled. Please save changes and re-try.")
End If
frmJCJob1.Find (":")
frmJCJob1.Prev
MyJob = val(frmJCJob1.JobCode) + 1
MyType = Left(InputList("Please select job type","Job Type","Contract","In House", _
"One Off", "Repairs","Specials"),1)
If IsNull(MyType) then Abort("Cancelled by user.")
frmJCJob1.Insert
frmJCJob1.JobCode = MyJob & MyType
frmJCJob1.Save
frmJCJob1.Edit