SubForm Problem

EssexRob

Registered User.
Local time
Today, 18:26
Joined
Jan 30, 2006
Messages
22
I have a minor problem with a subform

First of the all, the main form shows employees details and the sub form shows the work scheduled for that employee. I have binded the fields together.

It displays the first employees workschedule correctly in the sub form, however the problem is when i click on the next button the record in the subform does not update as well.

If it helps, this is the code i have so far....

Private Sub btnNext_Click()
UpdateRecords
rs.MoveNext
If rs.EOF Then
MsgBox "You have reached the last record", vbOKOnly, "Infomation"
rs.MoveLast
End If

FillControls

End Sub

Private Sub UpdateRecords()

txtClientName.SetFocus
rs.Fields.Item("Employee_Name") = txtClientName.Text
txtAddress.SetFocus
rs.Fields.Item("Address") = txtAddress.Text
txtTown.SetFocus
rs.Fields.Item("Town") = txtTown.Text
txtCounty.SetFocus
rs.Fields.Item("County") = txtCounty.Text
txtPostcode.SetFocus
rs.Fields.Item("Postcode") = txtPostcode.Text
txtTelephone.SetFocus
rs.Fields.Item("Telephone_No") = txtTelephone.Text
rs.UpdateBatch

End Sub
 
Private Sub UpdateRecords()

txtemployee.SetFocus
rs.Fields.Item("Employee_Name") = txtEmployeeName.Text
txtAddress.SetFocus
rs.Fields.Item("Address") = txtAddress.Text
txtTown.SetFocus
rs.Fields.Item("Town") = txtTown.Text
txtCounty.SetFocus
rs.Fields.Item("County") = txtCounty.Text
txtPostcode.SetFocus
rs.Fields.Item("Postcode") = txtPostcode.Text
txtTelephone.SetFocus
rs.Fields.Item("Telephone_No") = txtTelephone.Text
rs.UpdateBatch

End Sub

Sorry this is the correct code for the update records in case you noticed a schoolboy error on the last code.
 
If you are using bound controls then the UpdateRecords() code is unnecessary. If you are using the LinkChild/MasterFields of the SubFormControl properly then the SubForm should take care of itself.
 

Users who are viewing this thread

Back
Top Bottom