Thanks in advance for any help.
This involves a little VBA code and three MS Access tables.
1) SR. Technology Officer (tblSTO),
2) tblProjects,
3) tblDeliverables.
Among other fields, the STO table has an autonumber STO_ID (primary index) and the STO_Name (text).
The tblProject table has ProjectNo (text) and STO_ID. These two combined are unique and make the primary key.
The tblDeliverables table has ProjectNo, STO_ID, ServiceName (text). These three combined are unique and make the primary key.
I have a qryDeliverable query which includes all three tables and all the fields from each table. I have a form frmDeliverable which uses the qryDeliverables as the record source and has a combo box field to select the ProjectNo from the Project table. The ProjectNo, STOName (from STO table) are displayed in the combobox drop down.
Once ProjectNo is selected, I want the ProjectNo, STOName, and a couple other fields from the qryDeliverables displayed, and a field (DesignerPlanner) I try to populate using some VBA in an "After Update" event. It's not working. Depending on how I play with the relationships and the VBA code, it either doesn't populate the fields, or the add record controls for the form disappear, or I get some relationship error.
A little history....I had this working perfectly when using an autonumber ID field (primary index) in both the Project and Deliverable tables. However, a new requirement came in to be able to be able to pre-populate (one time) the Deliverables table via import from a spreadsheet of records. With the Project file already populated, the spreadsheet to be imported into the Deliverables table has unique project numbers (ProjectNo) and a common STO_ID across all the records (just as a starting point), but can't possibly have each project ID number, so the index requirement wasn't met. I had to delete the project ID field from the Deliverables table and use the ProjectNo and STO_ID combined as the primary index. This was the start of all my problems.
Here is the VBA code:
Private Sub Project_No_AfterUpdate()
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
If Not IsNull(ProjectNo) Then
Set rs = CurrentDb.OpenRecordset("qryProjects")
Me.STO_ID = rs!STO_ID
Me.DesignerPlanner = "Chiu, Derek;"
End If
End Sub
I hope this is clear and any help is appreciated. Thanks so much!