Hi,
I'm relatively new to using Excel to add records to an access database.
I have the following code that when the user presses the submit button it adds the record within access database.
I want to then replicate above for the colleagues manager, details of which are added to the "tbl_LineManagers" table in access. The "tbl_Colleagues" table contains a field called "ManagerID" which has a 1:M relationship from the LineManager table, however when I add a record this field remains blank.
How can I get it so that the "ManagerID" field in "tbl_Managers" is pulled through to the "ManagerID" field in "tbl_Colleagues"?
Thanks.
I'm relatively new to using Excel to add records to an access database.
I have the following code that when the user presses the submit button it adds the record within access database.
Code:
Set db = OpenDatabase(DatabasePath)
'Open the 'Lab_Submissions' table within the database
Set rst = db.OpenRecordset("tbl_Colleagues")
'This section populates the information in the UserForm into Access Database, depending on what table it is to go into.
On Error GoTo ErrorHandling
rst.AddNew
rst.Fields("ReferenceNumber") = UserForm1.txtbox_RefNum.Value
rst.Fields("FName") = UserForm2.txtbox_ColleagueFName.Value
rst.Fields("LName") = UserForm2.txtbox_ColleagueLName.Value
rst.Fields("Role") = UserForm2.txtbox_ColleagueRole.Value
rst.Fields("eMail") = UserForm2.txtbox_ColleagueEmail.Value
rst.Fields("PhoneNumber") = UserForm2.txtbox_ColleagueContactNum.Value
rst.Fields("Enrolled").Value = True
rst.Update
rst.Close
Set rst = db.OpenRecordset("tbl_LineManagers")
I want to then replicate above for the colleagues manager, details of which are added to the "tbl_LineManagers" table in access. The "tbl_Colleagues" table contains a field called "ManagerID" which has a 1:M relationship from the LineManager table, however when I add a record this field remains blank.
How can I get it so that the "ManagerID" field in "tbl_Managers" is pulled through to the "ManagerID" field in "tbl_Colleagues"?
Thanks.