Post #29, your text PK does not work becaues hte code is looking for a numerical value.
My schema was based on ONE NHS Number having multiple entries in tblAdmissions. Which required the Index, SGNumber and Date (which wsa all my misunderstandin g of your schema). In the new, normalized table, you just need the Index to tblAdmissions, but then we still need.
The purpose of showing you the filter is the only reason we had the assessments form have any fields on it. This was just to demonstrate what we were doing--PLUS, it was easier to use Me.txtAdmission Date for the Baseline. BUT, this is absolutely not necessary.
If we only have a blank for with nothing on it but a Combo box (form is unbound and does NOT have a record source), then just select a name from teh Combo Box. You would be selecting a SG Number (which is unique, but the Combo box would also have the index associated with the SG Number). Then pull up the assessment form based on the index and Date (because the assessments table could have the same Admissions Index but multiple dates.
We would have to slightly modify our code behind the buttons:
NB changes to the SQL statement, as well as Lines 14-19, since we no longer have a text box for the PatientID or the Assessment Date.
My schema was based on ONE NHS Number having multiple entries in tblAdmissions. Which required the Index, SGNumber and Date (which wsa all my misunderstandin g of your schema). In the new, normalized table, you just need the Index to tblAdmissions, but then we still need.
The purpose of showing you the filter is the only reason we had the assessments form have any fields on it. This was just to demonstrate what we were doing--PLUS, it was easier to use Me.txtAdmission Date for the Baseline. BUT, this is absolutely not necessary.
If we only have a blank for with nothing on it but a Combo box (form is unbound and does NOT have a record source), then just select a name from teh Combo Box. You would be selecting a SG Number (which is unique, but the Combo box would also have the index associated with the SG Number). Then pull up the assessment form based on the index and Date (because the assessments table could have the same Admissions Index but multiple dates.
We would have to slightly modify our code behind the buttons:
Code:
Option Compare Database Option Explicit Private Sub cmdBaseline_Click() Dim strSQL As String strSQL = "INSERT INTO tbl_HoNOS_Assessments " & _ "( Patient, AssessmentDate, ItemName ) " & _ "SELECT tbl_Admissions.PatientID, " & _ "tbl_Admissions.AdmissionDate, " & _ "tbl_HoNOS_Items.ItemKey " & _ "FROM tbl_Admissions, tbl_HoNOS_Items " & _ "WHERE tbl_Admissions.PatientID = " & Me.cboPatientID & ";" DoCmd.RunSQL strSQL DoCmd.OpenForm "frmAddAssessment", , , _ "Patient = " & Me.cboPatientID & _ " AND AssessmentDate = #" & _ DLookup("[AdmissionDate]", _ "tbl_Admissions", _ "[PatientID] = " & Me.cboPatientID) & "#" End Sub Private Sub cmdFollowup_Click() Dim strSQL As String strSQL = "INSERT INTO tbl_HoNOS_Assessments " & _ "( Patient, AssessmentDate, ItemName ) " & _ "SELECT tbl_Admissions.PatientID, #" & _ Date & "# AS AssessDate, " & _ "tbl_HoNOS_Items.ItemKey " & _ "FROM tbl_Admissions, tbl_HoNOS_Items " & _ "WHERE tbl_Admissions.PatientID = " & Me.cboPatientID & ";" DoCmd.RunSQL strSQL DoCmd.OpenForm "frmAddAssessment", , , _ "Patient = " & Me.cboPatientID & _ " AND AssessmentDate = #" & Date & "#" End Sub
Comment