Hi,
I have a form that is used to enter absence records, fairly basic but does the job for that.
When the form loads it loads to a new record, when an employee is chosen it checks the database to find all open records, these are then displayed in a sub form, this works fine.
If a record is found a msgbox popups up and asks the inputter if they wish to edit an existing record, if they say yes the main form is cleared and they can then choose a record from the sub form, this is where the problem lies, the sub form shows the correct existing record for the employee but when it loads the data into the main form it goes to the first record in the table not the record which was selected in the sub form.
example, agent 1 has existing record, but agent2 record is loaded
I have stepped through the link criteria and it says it is finding the correct id, but it loads a different ID into the form.
Here is the coding for the sub form click button
here is the code for on load event of the main form, the sub form should be sending the data back to the main form if they wish to edit the record, but it doesn't it always puts the first record in the table, not the selected record.
the main form is bound to a table.
Hope this is enough info, if not let me know.
Hope this is of use, Rob.
I have a form that is used to enter absence records, fairly basic but does the job for that.
When the form loads it loads to a new record, when an employee is chosen it checks the database to find all open records, these are then displayed in a sub form, this works fine.
If a record is found a msgbox popups up and asks the inputter if they wish to edit an existing record, if they say yes the main form is cleared and they can then choose a record from the sub form, this is where the problem lies, the sub form shows the correct existing record for the employee but when it loads the data into the main form it goes to the first record in the table not the record which was selected in the sub form.
example, agent 1 has existing record, but agent2 record is loaded
I have stepped through the link criteria and it says it is finding the correct id, but it loads a different ID into the form.
Here is the coding for the sub form click button
Code:
On Error GoTo Err_cmdedit_Click
Dim stDocName, stdocname2 As String
Dim stlinkcriteria As String
'stDocName = "frmLineManagerListing"
stlinkcriteria = Me.SicknessReference
stdocname2 = "frmAbsenceLogging"
DoCmd.OpenForm stdocname2, , , stlinkcriteria
Exit_cmdedit_Click:
Exit Sub
Err_cmdedit_Click:
MsgBox Err.Description
Resume Exit_cmdedit_Click
Code:
DoCmd.Maximize
With Me![frmSubAbsencesbyAgent].Form
.Visible = (.RecordsetClone.RecordCount > 0)
End With
the main form is bound to a table.
Hope this is enough info, if not let me know.
Hope this is of use, Rob.