Public Sub InsertParentRecord()
parent.CursorType = adOpenKeyset
parent.LockType = adLockOptimistic
parent.ActiveConnection = cn
parent.Open ("SELECT * FROM parent")
parent.AddNew
LocalDate = Date
LocalTime = Time
Date_Time = Date & " " & Time
parent.Fields("Date_Time").Value = Date_Time
parent.Fields("StartTime").Value = f1
parent.Fields("BatchNo").Value = f2
parent.Fields("Operator").Value = f3
parent.Update
parent.Close
End Sub
Public Sub InsertChildRecord()
parent.CursorType = adOpenKeyset
parent.LockType = adLockOptimistic
parent.ActiveConnection = cn
parent.Open ("SELECT * FROM parent")
Child.CursorType = adOpenKeyset
Child.LockType = adLockOptimistic
Child.ActiveConnection = cn
Child.Open ("SELECT * FROM Child")
If parent.EOF = True Then 'MoveLast is not supported.
parent.MoveFirst
While parent.EOF = False
CurrentIndex = parent.Fields(0).Value
parent.MoveNext
Wend
End If
While parent.EOF = False
CurrentIndex = parent.Fields(0).Value
parent.MoveNext
Wend
Child.AddNew
Child.Fields("index").Value = CurrentIndex
f1 = StartHour & ":" & StartMin
f2 = StopHour & ":" & StopMin
Child.Fields("StartTime").Value = f1
Child.Fields("StopTime").Value = f2
If Step_no = 1 Then
'IT FAILS HERE BECAUSE PARENT TABLE IS IN EOF.
parent.Fields("StartTime").Value = f1
End If
If Step_no = 3 Then
parent.Fields("StopTime").Value = f2
End If
parent.Update
Child.Update
Child.Close
parent.Close
End Sub