I have a DAO recordset I am using to loop through a subset of table records by building the recordset off of a SQL string.
If I put the SQL string in a new query, then I get 28 records. However, the .RecordCount of the recordset is only showing 1 with the same SQL code.
Can anyone give me any hints as to what might be going on?
Here's the code where this occurs:
And the table structure it is querying from is this:[tt]
Field DataType
ImportID AutoNumber
DateImported Text
FileName Text
ObjectName Text
ObjectType Text
ImportedBy Text
Approved Yes/No
[/tt]
The full table at the moment has 60 records in it.
Here is some sample data (well, I'll leave off irrelavent fields from examples, to make them fit on screen):
[tt]FileName ObjectName ObjectType Approved
FullPath.xls Sheet1 ws Yes
FullPath.xls Sheet2 ws Yes
FullPath1.xls Summary ws No
[/tt]
The field, "ObjectType", was one I came up with to specify whether the file was an Excel, Access, or text file.
The Yes/No field could be the problem, I suppose, but I was under the impression that you can relate to Yes/No the same as True/False. Is this not the case? Should I be using "Yes" instead of True?
I'll get back to trying that method in an hour or two, hopefully...
--
"If to err is human, then I must be some kind of human!" -Me
If I put the SQL string in a new query, then I get 28 records. However, the .RecordCount of the recordset is only showing 1 with the same SQL code.
Can anyone give me any hints as to what might be going on?
Here's the code where this occurs:
Code:
Private Sub ClickMe_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim QU As String
QU = Chr(34) [green]'Double Quote[/green]
strSQL = "SELECT i.* FROM tblImports i " & Chr(13) & Chr(9) & _
"WHERE (i.ObjectType = " & QU & "ws" & QU & ") AND " & Chr(13) & Chr(9) & _
"(i.Approved = True)"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
Do While Not rs.EOF
'Other Code here...
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
And the table structure it is querying from is this:[tt]
Field DataType
ImportID AutoNumber
DateImported Text
FileName Text
ObjectName Text
ObjectType Text
ImportedBy Text
Approved Yes/No
[/tt]
The full table at the moment has 60 records in it.
Here is some sample data (well, I'll leave off irrelavent fields from examples, to make them fit on screen):
[tt]FileName ObjectName ObjectType Approved
FullPath.xls Sheet1 ws Yes
FullPath.xls Sheet2 ws Yes
FullPath1.xls Summary ws No
[/tt]
The field, "ObjectType", was one I came up with to specify whether the file was an Excel, Access, or text file.
The Yes/No field could be the problem, I suppose, but I was under the impression that you can relate to Yes/No the same as True/False. Is this not the case? Should I be using "Yes" instead of True?
I'll get back to trying that method in an hour or two, hopefully...
--
"If to err is human, then I must be some kind of human!" -Me