My macro is writing to a table(T) and reading a query (Q) based on that
table (VBA/Visual Basic 6.3). I cannot write T and read Q in the same
execution of the macro, however, if I skip the writing part I can read
Q just fine.
How does closing the macro reset the state of the system?
The SQL for Q is--
SELECT Relatesto.contains, Relatesto.iscontained
FROM Relatesto GROUP BY Relatesto.contains, Relatesto.iscontained;
Thanks
Sub relater()
'
' Create a a file of conjunctive conditions on adjacent keywords
(conjunctive
' meaning found in the same document) The following rules are
created --
' 1. auto related - keyword -> keyword (itself)
' 2. forward - prime ref -> keyword
' 3. backward - keyword -> prime ref
' 4. secondary - if keyword1 -> keyword2 and keyword2 ->
keyword3 then
' keyword1 -> keyword3
'
Dim dbs As Database
Dim rstTags As Recordset, strquery As String
Dim rstRelatesto As Recordset, rstURelatesto As Recordset
Dim process1 As Integer, process2 As Integer
On Error GoTo Err_passTags
strquery = "SELECT * FROM tags WHERE tagType=1"
Set dbs = CurrentDb
Set rstTags = dbs.OpenRecordset(strquery, dbOpenDynaset)
MsgBox ("opened rstTags")
strquery = "SELECT * from Relatesto"
Set rstRelatesto = dbs.OpenRecordset(strquery, dbOpenDynaset)
MsgBox ("opened rstRelatesto")
'GoTo fubar
process1 = 0
rstTags.MoveFirst
While Not rstTags.EOF
rstTags.MoveNext
'
rstRelatesto.AddNew
rstRelatesto![contains] = rstTags![primeRef]
rstRelatesto![iscontained] = rstTags![primeRef]
rstRelatesto.Update
'
process1 = process1 + 1
Wend
fubar:
strquery = "SELECT * from UniqueRelatesto"
Set rstURelatesto = dbs.OpenRecordset(strquery, dbOpenSnapshot)
MsgBox ("opened rstURelatesto")
process2 = 0
rstURelatesto.MoveFirst
While Not rstURelatesto.EOF
rstURelatesto.MoveNext
process2 = process2 + 1
Wend
Exit_passTags:
rstRelatesto.Close
rstTags.Close
rstURelatesto.Close
MsgBox ("Created " & process1 & " primary records and " & process2
& " secondary records")
Exit Sub
Err_passTags:
MsgBox Err.Description
Exit Sub
End Sub