Hi All,
I thought opening a recordset (subset) within a recordset would be straightforward--evidently not.
Here's what I have:
I keep getting a data type conversion error. I'm opening a new recordset within an existing recordset based on a query. What's causing the data type conversion error?
Thanks
I thought opening a recordset (subset) within a recordset would be straightforward--evidently not.
Here's what I have:
Code:
Dim db As Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim sqlstr As String
Dim sqlstr1 As String
Dim sqlstrall As String
.....
sqlstr = "SELECT tblPeople.FamilyID, tblPeople.LastName, tblPeople.FirstName, " & _
"tblPeople.EmailAddress, tblPhone.PhoneNumber " & _
"FROM (tblFamily INNER JOIN tblPeople ON tblFamily.FamilyID = tblPeople.FamilyID) LEFT JOIN " & _
"tblPhone ON tblPeople.PeopleID = tblPhone.PeopleID "
Set db = CurrentDb
Set rs = db.OpenRecordset(sqlstr) 'this should limit all records to the search criteria
....
Select Case controlname.Name
Case subformname!FirstName.ControlSource
sqlstr1 = sqlstr & "WHERE (tblPeople.FirstName)= '" & inputstring & "' "
Case subformname!LastName.ControlSource
sqlstr1 = sqlstr & "WHERE (tblPeople.LastName) like '*" & inputstring & "' "
Case subformname!EmailAddress.ControlSource
sqlstr1 = sqlstr & "WHERE (tblPeople.EmailAddress)='" & inputstring & "' "
Case subformname![Phone].Form!PhoneNumber.ControlSource 'this is a sub-subform
sqlstr1 = sqlstr & "WHERE (tblPhone.PhoneNumber)='" & inputstring & "' "
End Select
'ck value of txtbookmark
If intfambookmark = 0 Then
sqlstrall = sqlstr1
Else
sqlstrall = sqlstr1 & " AND (tblPeople.FamilyID) > " & intfambookmark & ";"
End If
'set the next recordset within the first recordset
If Not rs.EOF Then
Set rs1 = rs.OpenRecordset(sqlstrall)
....
I keep getting a data type conversion error. I'm opening a new recordset within an existing recordset based on a query. What's causing the data type conversion error?
Thanks