Hello,
I am creating a query (the vba code is below) which extracts certain records from two different tables and shows the results in a form called frmQuestions.
Now, I want to assign values to Session ID, Patient ID and Session Date. These all will be passed as parameters to this module. How can I do it so that all the records that are extracted by this query get assigned the same values of Session ID, Patient ID and Session Date?
Also are these changes going to get written to the table automatically?
Set dbs = CurrentDb
strQueryName = "qryQuestionnaire"
For Each q In dbs.QueryDefs
If q.Name = strQueryName Then
dbs.QueryDefs.Delete strQueryName
End If
Next
strSQL = "SELECT ASK.SESSION_ID, ASK.PATIENT_ID, ASK.SESSION_DATE, QUESTION.QUES_STATEMENT, ASK.ANSWER FROM QUESTION LEFT JOIN ASK ON QUESTION.QUES_ID=ASK.QUES_ID WHERE (((QUESTION.QUESN_ID)= " & num & "));"
'Create query definition
Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)
DoCmd.OpenForm "frmQuestions", acNormal
I am creating a query (the vba code is below) which extracts certain records from two different tables and shows the results in a form called frmQuestions.
Now, I want to assign values to Session ID, Patient ID and Session Date. These all will be passed as parameters to this module. How can I do it so that all the records that are extracted by this query get assigned the same values of Session ID, Patient ID and Session Date?
Also are these changes going to get written to the table automatically?
Set dbs = CurrentDb
strQueryName = "qryQuestionnaire"
For Each q In dbs.QueryDefs
If q.Name = strQueryName Then
dbs.QueryDefs.Delete strQueryName
End If
Next
strSQL = "SELECT ASK.SESSION_ID, ASK.PATIENT_ID, ASK.SESSION_DATE, QUESTION.QUES_STATEMENT, ASK.ANSWER FROM QUESTION LEFT JOIN ASK ON QUESTION.QUES_ID=ASK.QUES_ID WHERE (((QUESTION.QUESN_ID)= " & num & "));"
'Create query definition
Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)
DoCmd.OpenForm "frmQuestions", acNormal