Using previous record on form with subforms

Ben McCall

Registered User.
Local time
Today, 04:18
Joined
Jun 20, 2001
Messages
22
I have a database in access 97.

I have a questionnaire form whose table is “question” which has three fields – “question_id”, “question_no”, and “question”.

One subform has a table “answers” which has four fields – “answer_id”, “answer_no” , “question_no and “answer”. The answers are multiple choice and one answer is selected for each question by clicking on the appropriate field in the subform (there are a maximum of four answers per question.)

The second subform has a table “patientsanswers” which has four fields – “patient –id”, “question_no”, answer_no”, and “answer”. This form is used for the answer to questions that are not multiple choice but require a numerical or text answer. This is also the table that stores all of the answers – both multiple choice and text.

I have no trouble with answering the questions and their going to the proper field in the “patientanswers” table but when I use a command button on the parent form to go to the previous record using “DoCmd.GoToRecord, , acPrevious” I am returned to the proper answer field but the content is that of the previous set of question’s answer i.e. I get the answer for “patient_id” “1” when patient_id” “2” is the current responder. Also the answer for “patient_id” “1” is changed to the current responders “patient_id” number. I know this is complicated but I wondered whether any one had a solution to the problem.

It is possible that I need to look this field up using the “patient_id” field but I have not been able to accomplish this to date.

Any help would be appreciated. If you need more information please ask.

Thanks!

Ben McCall


[This message has been edited by Ben McCall (edited 07-28-2001).]
 
I am a little confused by your question.

You say you want to go to the previous record, and yet when the form returns to say patient ID 1 you say that is not what you want?

You imply that you are trying to return to a previous field not a previous record is this waht you are trying to do?
 
I'm also a little confused by your question.

i'm kind of guessing here, but i think you need to do a Requery on your subforms when you MovePrevious on you main form...

hth,
al
 
The form is set up so that only one question is on a page. Therefore the answer to each question is a seperate record in "patientanswers" identified by the field "patient_id". If the responder is "patient_id" 5 and clicks on the previous field button on the main form, the subform will show the correct box but the "answer" will be that of "patient_id" 1. At that time the "answer" from "patient_id" 1 is relabeled "patient_id" 5 and that"question_no" for "patient_id" 1 is no longer in the table.

If subsequent responders, i.e., "patient_id" 10 click on the previous field button the "answer" that had been relabeled "patient_id" 5 above will appear in the "answer" field and is now labeled "patien_id" 10.

I know that this is confusing but I have explained above exactly what is occurring. I have tried "requery" "recordsource" to no avail.

Thanks Again!

Ben McCall
 
Open form in design mode. Get to the properties of the subform. Select tabpage other. Go to the third property there, change (there are only 3 options) . The property is named Tabkey functioning (my version is dutch).
 
You need to set your relationships between Patients and Answers. Answers has a one to many with Patients, having done that you need to link your subforms to the main form, Link master/child field on the forms property sheet.
HTH
 

Users who are viewing this thread

Back
Top Bottom