Hello Guys,
I need some help on my vba code. What I am trying to do is add a new record to a subform. If there is only one record then the value is 100%. But if you add another record, then it should split the value depending on whatever percentage you assigned them. The value will be taken on another form basically.
This is the code i have at the moment. The thing is it applies the 100% on the first record and when i add another record it will assign the split value on the 2nd record but not the 1st one. Obviously the value of the 1st record remain to 100%.
Can please somebody help or guide me through. Thank you.
I need some help on my vba code. What I am trying to do is add a new record to a subform. If there is only one record then the value is 100%. But if you add another record, then it should split the value depending on whatever percentage you assigned them. The value will be taken on another form basically.
This is the code i have at the moment. The thing is it applies the 100% on the first record and when i add another record it will assign the split value on the 2nd record but not the 1st one. Obviously the value of the 1st record remain to 100%.
Can please somebody help or guide me through. Thank you.
Code:
Private Sub Form_AfterInsert()
Dim myDB As Database
Set myDB = CurrentDb
Dim rst As Recordset
Set rst = myDB.OpenRecordset("tblLaborCost8")
If Me.Recordset.RecordCount = 1 Then
Me.SplitPercent = 1
ElseIf Me.Recordset.RecordCount >= 2 Then
rst.MoveFirst
While Not rst.EOF
If Me.JobTitleID = "Qualified CS Fitter - Expat" Or Me.JobTitleID = "Qualified CS Fitter - Local" Then
Me.SplitPercent = Forms![ProjectDetails].Title08Split1
ElseIf Me.JobTitleID = "Qualified CS Welder - Expat" Or Me.JobTitleID = "Qualified CS Welder - Local" Then
Me.SplitPercent = Forms![ProjectDetails].Title08Split2
End If
rst.MoveNext
Wend
End If
rst.Close
Set rst = Nothing
Set myDB = Nothing
End Sub