I'm facing a problem and I really appreciate eny help with this.
In my continuous form I have this query in the record source
SELECT DISTINCT TBL_Institutions.* FROM TBL_Institutions INNER JOIN Tbl_FieldInstitJctTbl ON TBL_Institutions.InstitCode = Tbl_FieldInstitJctTbl.InstitCode WHERE M<>"" AND MajorCode='NUTR' AND ELI_CoopClass='ELS' AND M<>"H" AND G_CLA=True AND Country="USA" AND TBL_Institutions.City in ('Boone','Thousand Oaks','Clemson','Cleveland','Chico','Washington','Teaneck','Melbourne','Erie','Terre Haute','Harrisonburg','Ruston','Milwaukee','West Long Branch','Murfreesboro','Billings','Bozeman','Las Cruces','Socorro','Dekalb','Oklahoma City','Rapid City','Edwardsville','Philadelphia','Marietta','Cincinnati','Colorado Spring','Denver','Dayton','Houston','North Dartmouth','St Louis','Missoula','Grand Forks','West Haven','St Paul','Laramie','Wichita') UNION SELECT DISTINCT TBL_Institutions.* FROM TBL_Institutions INNER JOIN Tbl_FieldInstitJctTbl ON TBL_Institutions.InstitCode = Tbl_FieldInstitJctTbl.InstitCode WHERE M<>"" AND MajorCode="CSCI" AND ELI_CoopClass="ELS" AND M<>"H" AND G_CLA=True
AND Country="USA" AND TBL_Institutions.City in ('Chico','Cleveland','Pocatello','Terre Haute','Ruston','Dekalb','Cincinnati','West Haven','Rock Hill')
The form is working fine and I'm able to view the results. The issue is that I need to store the output (query values) in another table so I added a button that will go thru all the records in the record source
Private Sub Command2_Click()
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Debug.Print Me.RecordSource
Set rs = db.OpenRecordset(Me.RecordSource, dbOpenDynaset)
If rs.EOF Then
Else
Do While Not (rs.EOF)
Debug.Print "Instit= " & rs("InstitCode")
rs.MoveNext
Loop
End If
rs.Close
db.Close
End Sub
Whenever I run the above code I got the following error in this line
Debug.Print "Instit= " & rs("InstitCode")
The search key was not found in any record. (Error 3709)
So can anybody explain the cause of such an error.
Thanks in advance.
Lina
In my continuous form I have this query in the record source
SELECT DISTINCT TBL_Institutions.* FROM TBL_Institutions INNER JOIN Tbl_FieldInstitJctTbl ON TBL_Institutions.InstitCode = Tbl_FieldInstitJctTbl.InstitCode WHERE M<>"" AND MajorCode='NUTR' AND ELI_CoopClass='ELS' AND M<>"H" AND G_CLA=True AND Country="USA" AND TBL_Institutions.City in ('Boone','Thousand Oaks','Clemson','Cleveland','Chico','Washington','Teaneck','Melbourne','Erie','Terre Haute','Harrisonburg','Ruston','Milwaukee','West Long Branch','Murfreesboro','Billings','Bozeman','Las Cruces','Socorro','Dekalb','Oklahoma City','Rapid City','Edwardsville','Philadelphia','Marietta','Cincinnati','Colorado Spring','Denver','Dayton','Houston','North Dartmouth','St Louis','Missoula','Grand Forks','West Haven','St Paul','Laramie','Wichita') UNION SELECT DISTINCT TBL_Institutions.* FROM TBL_Institutions INNER JOIN Tbl_FieldInstitJctTbl ON TBL_Institutions.InstitCode = Tbl_FieldInstitJctTbl.InstitCode WHERE M<>"" AND MajorCode="CSCI" AND ELI_CoopClass="ELS" AND M<>"H" AND G_CLA=True
AND Country="USA" AND TBL_Institutions.City in ('Chico','Cleveland','Pocatello','Terre Haute','Ruston','Dekalb','Cincinnati','West Haven','Rock Hill')
The form is working fine and I'm able to view the results. The issue is that I need to store the output (query values) in another table so I added a button that will go thru all the records in the record source
Private Sub Command2_Click()
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Debug.Print Me.RecordSource
Set rs = db.OpenRecordset(Me.RecordSource, dbOpenDynaset)
If rs.EOF Then
Else
Do While Not (rs.EOF)
Debug.Print "Instit= " & rs("InstitCode")
rs.MoveNext
Loop
End If
rs.Close
db.Close
End Sub
Whenever I run the above code I got the following error in this line
Debug.Print "Instit= " & rs("InstitCode")
The search key was not found in any record. (Error 3709)
So can anybody explain the cause of such an error.
Thanks in advance.
Lina