Results 1 to 3 of 3
  1. #1
    jmstauf is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2024
    Posts
    2

    How to use data from a query to fill in a table field?

    I have been searching everywhere for how to do this, and think it's just that I'm not phrasing it right as I can't find the answer I'm looking for. Here is the basic table data and query I am using to give a point of reference to start:

    QuestionT PopQuizQ PopQuizT
    QuestionID QuestionID PopQuizID
    Topic Question Question1
    Question Answer Question2
    Answer Points ....Question 5
    Points RND(selects 5 Random Questions)

    So QuestionT is a question data bank that the PopQuizQ uses to generate 5 random questions, and produces a "record" for each question. How can I then have access take the QuestionID field from PopQuizQ and input it into PopQuizT as the individual questions? I am currently manually doing this, but was wondering if there was an automatic way to speed up the data entry side?

    Here's what I want to do using what I am seeing in my output to put into context what I want it to do:

    PopQuizQ Output

    QuestionID Question Answer Points
    10 What color is the sky? Blue 1
    36 What color is grass? Green 1
    4 Is water wet? Yes 1
    102 Are dogs cool? Yes 1
    75 Is the sun hot Yes 1

    PopQuizT Input

    PopQuizID Question 1 Question 2 Question 3 Question 4 Question 5


    1 10 36 4 102 75

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    PopQuizT is not normalized structure.

    PopQuizT should be a parent table then have a related table that stores selected questions for quiz.
    Have a form for creating PopQuizT parent record then use code to write query records to QuizQuestionsT.
    Something like:

    Code:
    If Me.Dirty Then
    Me.Dirty = False
    CurrentDb.Execute "INSERT INTO QuizQuestionsT(PopQuizID_FK, QuestionID_FK) SELECT " & Me.tbxQuizID & ", Rnd(...) FROM QuestionsT"
    End If
    The event to run code could be button Click.

    What other data could go in PopQuizT - QuizDate, QuizProctor, QuizRespondent, etc. ?


    Suggest you learn to use forum table builder on the Advanced editor. Can even copy/paste from Excel or Access.

    Following is how I interpret your data info:

    QuestionT PopQuizQ PopQuizT
    QuestionID PopQuizID Question1
    Topic RND() QuestionID Question2
    Question Answer Question3
    Answer Points Question4
    Question5


    PopQuizQ Output

    QuestionID Question Answer Points
    10 What color is the sky? Blue 1
    36 What color is grass? Green 1
    4 Is water wet? Yes 1
    102 Are dogs cool? Yes 1
    75 Is the sun hot? Yes 1

    Last edited by June7; 04-16-2024 at 11:15 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jmstauf is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2024
    Posts
    2
    Thanks for the quick reply. I apologize for the formatting of the tables. It looked good when inputting them, but changed once I hit post.

    Appreciate the assistance. I will give that a try.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 06-23-2021, 12:11 PM
  2. Replies: 14
    Last Post: 03-15-2017, 08:33 PM
  3. Replies: 15
    Last Post: 11-11-2016, 10:41 AM
  4. Replies: 3
    Last Post: 03-07-2014, 10:39 AM
  5. Replies: 6
    Last Post: 09-10-2012, 07:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums