Click to See Complete Forum and Search --> : Inserting data into database


hmurti17
May 11th, 2001, 01:06 AM
I doing a project on online exam. There are two tables question table and subject table(Access database). In the subject table there are two fields sub_id and sub_name. In the question table there is sub_id field. In the dataentry screen there is a combo box of subject name. I want that while data entry when the user selects the subject name from the combobox the corresponding subject id should be entered in the question table.

I will be thankful if some one could suggest some code to solve the above query.

Andrew_Fryer
May 11th, 2001, 04:08 AM
Try this using a recordset

INSERT INTO QUESTIONS (SUBJECT_ID)
VALUES (
SELECT SUBJECT_ID FROM SUBJECTS
WHERE SUBJECT NAME = '<subject_name>');

Hope this helps

Andrew