bigtimmystyle
New member
- Local time
- Yesterday, 19:00
- Joined
- Aug 17, 2015
- Messages
- 2
I need some help with the commented out parts of the following code. I have searched high and low for a complete solution, but, can only find parts and cant seem to frankenstein it together.
Thanks for any assistance given.
Tim
Code:
Dim rstSource As DAO.Recordset
Dim rstTarget As DAO.Recordset
Dim dbs As DAO.Database
Dim strLines() As String
Dim strLine As String
Dim i As Long
On Error GoTo ErrHandler
Set dbs = CurrentDb
Set rstSource = dbs.OpenRecordset("SELECT QuestionID, Type FROM MyQuestions", dbOpenDynaset)
Set rstTarget = dbs.OpenRecordset("SELECT QuestionID, Type FROM MyAnswers WHERE QuestionID Not Like '*'", dbOpenDynaset)
Do While Not rstSrc.EOF
strLines = rstSource!QuestionID 'this is what I want to edit/update into the target recordset, but
' I also need the value for each row of this array's "Type" for evaluating/comparing to choose the approriate
' record to insert it into rstTarget
For i = 0 To UBound(strLines)
' strLine = strLines(i) 'not sure if this is necessary as QuestionID is a number
' if above is not necessary, next line should say strLines, if not, should say strLine
If strLines <> "" Then
' need to somehow open up rstTarget to evaluate/edit each record and compare it's "Type" value
' to the value captured in strLines: "Type"
' where they match, it needs to update the first three consecutive ones with strLines array's current
' QuestionID value into rstTarget!QuestionID
' then move onto next strLines and onto the next record not edited/updated in rstTarget
' and do the same until the whole table is updated
' I need help with the commented out parts and any bits that need to change above it to make this work
' end result will be three of each QuestionID being added into blank QuestionID field in rstTarget
' where the "Type" value of rstStrines matched rstTarget "Type"
' the records in each table are populated in random order by append queries/deleted by delete queries
' this is used for temporary tables that get wiped out after each test, so, that is why I am
' doing it this way. The link between both tables is QuestionID. After this works, the table records are linked
' on each QuestionID. This avoids having to sit down and manually type each quesiton/four answers manually
' and the data never changes. Random tests keep up the learning experience.
Tim