T
Ted
I have a section of code something like this. Note the => lines for
explanation. Can someone help me figure out why I am getting this error?
Thanks.
Dim dbs As Database
Dim rstCategories As Recordset
Dim rstAds As Recordset
Dim CategoryFile As New Collection
Dim strKey As String
Dim strFile As String
Set dbs = CurrentDb
Set rstCategories = dbs.OpenRecordset("qryAdCategories")
Set rstAds = dbs.OpenRecordset("Items for Sale")
rstCategories.MoveFirst
While Not rstCategories.EOF
strKey = rstCategories.Fields("CatName")
CategoryFile.Add rstCategories.Fields("CatFile"), strKey
strFile = gcInHTMLDir & "\" & CategoryFile.Item(strKey)
=> The above code works OK
.... more code ...
rstCategories.MoveNext
Wend
rstAds.MoveFirst
While Not rstAds.EOF
strThisCategory = rstAds.Fields("Category")
strFile = gcInHTMLDir & "\" & CategoryFile.Item(strThisCategory)
=> The line above does NOT work!
=> Get a "Run-time error: '3021' No current record"
=> This error is supposedly for a recordset, which is not applicable, I
think.
=> It's basically the same code that worked in the While loop above, but
does not
=> work in this one. Any ideas?
... more code ....
rstAds.MoveNext
Wend
explanation. Can someone help me figure out why I am getting this error?
Thanks.
Dim dbs As Database
Dim rstCategories As Recordset
Dim rstAds As Recordset
Dim CategoryFile As New Collection
Dim strKey As String
Dim strFile As String
Set dbs = CurrentDb
Set rstCategories = dbs.OpenRecordset("qryAdCategories")
Set rstAds = dbs.OpenRecordset("Items for Sale")
rstCategories.MoveFirst
While Not rstCategories.EOF
strKey = rstCategories.Fields("CatName")
CategoryFile.Add rstCategories.Fields("CatFile"), strKey
strFile = gcInHTMLDir & "\" & CategoryFile.Item(strKey)
=> The above code works OK
.... more code ...
rstCategories.MoveNext
Wend
rstAds.MoveFirst
While Not rstAds.EOF
strThisCategory = rstAds.Fields("Category")
strFile = gcInHTMLDir & "\" & CategoryFile.Item(strThisCategory)
=> The line above does NOT work!
=> Get a "Run-time error: '3021' No current record"
=> This error is supposedly for a recordset, which is not applicable, I
think.
=> It's basically the same code that worked in the While loop above, but
does not
=> work in this one. Any ideas?
... more code ....
rstAds.MoveNext
Wend