update query; want to also update the field that links the two tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #16
    OK now having read through the thread again this is what I think is happening. You have data somewhere probably excel which contains the Notes data as in it is a record of all the notes so far. However, this information is not tied to the studentid in the database and therefore when you upload it there is no way to tie a note to a student.

    If that is the case this takes us back to NeoPa's post no. 9. You have to have some way to relate the data you are uploading to the student or you just can't do what you want to do. As I see it your options are ...
    • Add the studentid manually to each note record before uploading it or after.
    • Find another field or fields which tie the records together like student name.


    Otherwise you just can't do this.

    Comment

    • mjvm
      New Member
      • Oct 2008
      • 52

      #17
      Thank you.

      As I struggled to explain what I needed, I was starting to think it might not be possible.

      Thank you MSquared, NeoPa and Adezii for your time and patience - and your skills!

      Comment

      • mjvm
        New Member
        • Oct 2008
        • 52

        #18
        An alternative solution - would be to export the qryChase to excel including StudentID (from tblStudents), then add the notes information that I want, and import back to Access into tblNotes, renaming StudentID to NotesStudentID so that it provides the reference.
        ? Maybe

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #19
          That should work but remember if you have more than one note for a student that is a separate record. You only need to add studentid to notes information.

          Comment

          • mjvm
            New Member
            • Oct 2008
            • 52

            #20
            yep - I get that.

            Thank you and till my next challenge...... .. I hope you all keep well!

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #21
              How about for every [StudentID] in qryChase, you programmaticall y Add a corresponding Record in tblNotes consisting of that [StudentID], then it is simply a matter of Updating tblNotes?

              P.S. - tblNotes will now contain Records consisting of [NotesStudentID] for every [StudentID] in qryChase.

              Comment

              • mjvm
                New Member
                • Oct 2008
                • 52

                #22
                That sounds like a good idea, but I don't know how to do that. Is it difficult or complicated to code?

                Cheers,
                Marcella

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #23
                  The code assumes that there is only a single Record in qryChase relating to each Student:
                  Code:
                  Dim MyDB As DAO.Database
                  Dim rst As DAO.Recordset
                  
                  Set MyDB = CurrentDb
                  Set rst = MyDB.OpenRecordset("qryChase", dbOpenForwardOnly)
                  
                  With rst
                    Do While Not .EOF
                      'Insert Only if StudentID does not already exist in tblNotes
                      If DCount("*", "tblNotes", "[NoteStudentID] = " & ![StudentID]) = 0 Then
                        CurrentDb.Execute "INSERT INTO tblNotes ([NoteStudentID]) VALUES (" & _
                                           ![StudentID] & ")", dbFailOnError
                      End If
                        .MoveNext
                    Loop
                  End With
                  
                  rst.Close
                  Set rst = Nothing

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32634

                    #24
                    Originally posted by mjvm
                    As I struggled to explain what I needed, I was starting to think it might not be possible.
                    Sometimes (read nearly always) the biggest problem involved is the communication of the problem between member and experts.

                    Perhaps we should have a forum for problem expression (Only half joking). I'm saying you're certainly not alone in finding that difficult.

                    Comment

                    • ADezii
                      Recognized Expert Expert
                      • Apr 2006
                      • 8834

                      #25
                      I thought that it was only me that found this Thread difficult to pick apart.

                      Comment

                      • mjvm
                        New Member
                        • Oct 2008
                        • 52

                        #26
                        I am about to have a go at using the code - wish me luck!

                        I really thought that I was being as clear as I possibly could - written communication shouldn't be this hard!

                        :)

                        Comment

                        • ADezii
                          Recognized Expert Expert
                          • Apr 2006
                          • 8834

                          #27
                          You have to appreciate how difficult, as least for me, it is at times to understand a problem, then to come up with a viable solution at the other end of a Web Page.

                          Comment

                          • mjvm
                            New Member
                            • Oct 2008
                            • 52

                            #28
                            Of absolutely - I was completely aware that it was me not getting my message across and that I wasn't being clear or detailed enough for you guys.

                            What is difficult is not having the right words - the terminology - to ask the question. You don't get the answer you need if you don't - or can't - write the right question

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32634

                              #29
                              On the other hand, though sometimes it's strained, I think we're all getting better at reading between the lines. I feel positively psychic sometimes.

                              Best results are always achieved when the question is expressed clearly though of course.

                              A technique I always use (Yes. I post technical questions too sometimes.) is to build up a logical structure. I avoid referring to anything in my explanation that is not already explained. Think of a pyramid. Very solid and stable. That's because everything that is not on the ground is on all the other stuff that's already solidly founded.

                              I always refer to items by the same name too. Never "... tblAccount ... The Accounts table ..." as this interferes with the reader's ability to catalogue their understanding internally.

                              Comment

                              • mjvm
                                New Member
                                • Oct 2008
                                • 52

                                #30
                                Oh my goodness! It worked.

                                Thank you so much for the code ADezii, and thank you to NeoPa, MSquared and ADezii for your patience and persistence in "unpicking the thread".

                                Regards,
                                marcella

                                Comment

                                Working...