Hi
I have two recordsets one based on a query:
'query to get recordset of booked products per student
StrSelect = "SELECT STUDENT.StudentID, COURSEBK.[COURSE-DSName]"
StrFrom = "FROM STUDENT INNER JOIN COURSEBK ON STUDENT.StudentID = COURSEBK.[STUDENT-DSN]"
StrWhere = "WHERE (((STUDENT.StudentID)=" & StrStudentId & "));"
StrQuery = StrSelect & StrFrom & StrWhere
Set RstBookedCheck = db.OpenRecordset(StrQuery)
and a second based on a products table:
'a recordset of a 'new' products table
Set RstProductCheck = db.OpenRecordset("TblProduct")
I need to check if the booked product code is a new product or old product so my idea was to go through the first recordset line by line and check the product code against the entries in the new product table.
if any of the booked items appear in there then i know they have new products against the student otherwise the student is booked with old products (that dont appear in the product table) by mutual exclusion.
so i started in this vein:
' make sure something in the recordset
If Not RstBookedCheck.BOF And Not RstBookedCheck.EOF Then
' items in recordset
With RstBookedCheck
' go through each row of first recordset until eof
Do While Not .EOF
get the product code from first row
strCriteria = "[product code]='" & .Fields(2).Value & "'"
'now check if that product appears in the product table
With RstProductCheck
.FindFirst strCriteria
End With
.MoveNext
Loop
End With
Else
' no items in course booking table
End If
'******************************
I was not sure how to test if the findfirst was true so i can set the searchflag to true if a product was found or false if not and not sure either if i got the loops correct.
regards in advance for help.
Peter
I have two recordsets one based on a query:
'query to get recordset of booked products per student
StrSelect = "SELECT STUDENT.StudentID, COURSEBK.[COURSE-DSName]"
StrFrom = "FROM STUDENT INNER JOIN COURSEBK ON STUDENT.StudentID = COURSEBK.[STUDENT-DSN]"
StrWhere = "WHERE (((STUDENT.StudentID)=" & StrStudentId & "));"
StrQuery = StrSelect & StrFrom & StrWhere
Set RstBookedCheck = db.OpenRecordset(StrQuery)
and a second based on a products table:
'a recordset of a 'new' products table
Set RstProductCheck = db.OpenRecordset("TblProduct")
I need to check if the booked product code is a new product or old product so my idea was to go through the first recordset line by line and check the product code against the entries in the new product table.
if any of the booked items appear in there then i know they have new products against the student otherwise the student is booked with old products (that dont appear in the product table) by mutual exclusion.
so i started in this vein:
' make sure something in the recordset
If Not RstBookedCheck.BOF And Not RstBookedCheck.EOF Then
' items in recordset
With RstBookedCheck
' go through each row of first recordset until eof
Do While Not .EOF
get the product code from first row
strCriteria = "[product code]='" & .Fields(2).Value & "'"
'now check if that product appears in the product table
With RstProductCheck
.FindFirst strCriteria
End With
.MoveNext
Loop
End With
Else
' no items in course booking table
End If
'******************************
I was not sure how to test if the findfirst was true so i can set the searchflag to true if a product was found or false if not and not sure either if i got the loops correct.
regards in advance for help.
Peter