I have a form called Applicants. Inside the form is sub-form called InterviewReview. On that form I have an unbound text field labeled Text26. I want to update a table called INTVAnswers with the text typed into the Text26 filed. The button works when I put the applicantID in the code as whatever number it actually is. However, I am trying to get the expression to recognize the ApplicantID from the parent form and I am not having any success. Here is what I have so far. If someone could tell me what I need to do to fix this expression I would be very appreciative.
Private Sub AddCom_Click()
On Error GoTo AddCom_Click_Err
Dim dbs As Database
Set dbs = CurrentDb
'If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = 1;"
' Works inserts into Com1 text26 where the applicantid = whatever number I put there in the code.
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = & Forms!Applicants![ApplicantID];"
' Error = "Syntax error (missing operator) in query expression 'ApplicantID = & Forms!Applicants![ApplicantID]'
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = '" & Forms!Applicants![ApplicantID] & "';"
' Error = "Data type mismatch in criteria expression"
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms!Applicants![ApplicantID];"
' Error = "Too few Parameters. Expected 1."
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Form!Applicants![ApplicantID];"
' Error = "Too few Parameters. Expected 1."
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms.Applicants.[ApplicantID];"
' Error = "Too few Parameters. Expected 1."
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Form.Applicants.[ApplicantID];"
' Error = "Too few Parameters. Expected 1."
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms!Applicants!ApplicantID;"
' Error = "Too few Parameters. Expected 1."
' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms.Applicants.ApplicantID;"
' Error = "Too few Parameters. Expected 1."
AddCom_Click_Exit:
Exit Sub
AddCom_Click_Err:
MsgBox Error$
Resume AddCom_Click_Exit
End Sub