PDA

View Full Version : Please help -- read / write to different tables



abc123
07-11-2005, 05:08 PM
Hello,
I am trying to do a very simple thing in Access. I have 2 tables one is tblQuestions and the other is tblProjectQuestions.

In an MS Access 2000 form that actually uses these forms, I need to be able to first query from tblProjectQuestions to see if for a particular project, the questions have been answered. (I am passing the ProjectID as a parameter to the form). If the result of this query is null, then I need to read all the Questions from tblQuestions and display on the form.

On form close, I need to be able to either write records to tblProjectQUestions or update records in tblProjectQuestions depending on whether the questions exist or not.

Can anybody please point me to some code samples that helps me do the above?

Your help is greatly appreciated.

xCav8r
07-13-2005, 05:55 AM
Attach a sample database (remove all confidential data first!) that contains the tables, queries, and forms in question, and I'll give you the code you want.

abc123
07-13-2005, 08:08 PM
Attached is are the relevant tables, queries and forms. What I am trying to do is to read from tblQuestions and write all the questions per project and the corresponding responses to tblProjQuestions. I want to do this via code since I will have to do a lot of validation prior to inserting -

To be more specific, on form open, I need to first check if questions exist for a given project (the projID will be supplied to the form, so Me.OpenArgs should work) in tblProjquestions;

If they exist, then read from tblProjQuestions and display the questions and corresponding response;

If not, read from tblQuestions and write all the questions with a default responses (value = 3)

Then on form close, I need to be able to update the responses.

Any assistance is greatly appreciated.

Thanks

xCav8r
07-13-2005, 08:18 PM
Boy, when you got rid of the data, you really got rid of the data. :p

abc123
07-14-2005, 05:04 AM
Sorry, as you can imagine, these 2 tables are part of a larger database. I just thought it was easier to recreate the relevant parts of the database -- so, I created tables, queries, and the one form in order to post. Any assistance is greatly appreciated.

xCav8r
07-14-2005, 07:32 AM
No worries. I was only joking. I had meant to upload a few sample changes you might consider before leaving the computer for the night, but I forgot. Anyway, here it is. Take from it whatever you will. In the meantime, I'll grab this new file and give you the code you want tonight after I get home from work.