CallMeAndy
Registered User.
- Local time
- Today, 05:54
- Joined
- Jun 21, 2005
- Messages
- 14
Several issues here - something has gone a muck with a subform and not sure whether they all might point to the same thing.
Context.
A database serving as an encyclopedia, without all the fields mentioned the encyclopedia table has:
An ID.
A reference field.
A details field.
A subform is linked to the main form in the normal way with a master child methodology.
The subform displays a temporary table which is a list of cross references.
Each time the main form moves to a different record, in the current event a temp table has all records deleted and a new set is established by searching in the details field of all records in the encyclopedia field, a manual button also searches external word docs associated with the data and extends the temp table. Giving a mixture of other records and external references to the current encyclopedia item.
The tables are deleted and established in all cases as they should be, there are no data issues. It is just about display.
Problems:
Firstly the firing order of the form load events has become somehow inverted: current-open-load
rather than the other way around
the current event is firing twice per navigation
and the following two lines are exhibiting different behaviour which I did not expect:
Form_References.Form.Requery
Forms![Encyclopedia Namadan]!References.Form.Requery
I need the second to get correct data, the first is not clearing Deleted records, but the second causes an Error message at when it is run;
the control not recognised message pops up.
Obviously I am trying to work around the apparent anomolies as I dont seem to have a choice, but things are provioing a bit difficult.
Here is a cut down version of the salient points in the code:
Context.
A database serving as an encyclopedia, without all the fields mentioned the encyclopedia table has:
An ID.
A reference field.
A details field.
A subform is linked to the main form in the normal way with a master child methodology.
The subform displays a temporary table which is a list of cross references.
Each time the main form moves to a different record, in the current event a temp table has all records deleted and a new set is established by searching in the details field of all records in the encyclopedia field, a manual button also searches external word docs associated with the data and extends the temp table. Giving a mixture of other records and external references to the current encyclopedia item.
The tables are deleted and established in all cases as they should be, there are no data issues. It is just about display.
Problems:
Firstly the firing order of the form load events has become somehow inverted: current-open-load
rather than the other way around
the current event is firing twice per navigation
and the following two lines are exhibiting different behaviour which I did not expect:
Form_References.Form.Requery
Forms![Encyclopedia Namadan]!References.Form.Requery
I need the second to get correct data, the first is not clearing Deleted records, but the second causes an Error message at when it is run;
the control not recognised message pops up.
Obviously I am trying to work around the apparent anomolies as I dont seem to have a choice, but things are provioing a bit difficult.
Here is a cut down version of the salient points in the code:
Code:
Private Sub Form_Current()
Dim dbs As DAO.Database
Set dbs = CurrentDb
dbs.Execute "Delete * from references"
dbs.Close
'After deleting previous references find current set of references
searchForRefs()
'Requery the subform to get rid of deleted entries
Forms![Encyclopedia Namadan]!References.Form.Requery
'Form_References.Form.Requery
end sub
Private Sub searchForRefs()
'construct search as a compound of the general search conditions and an exclusion from finding itself
strSQL = "SELECT * FROM Encyclopedia WHERE Ref <> '" & Forms![Encyclopedia Namadan]![Ref] & "'" & strConditions
Set rstEnc = dbs.OpenRecordset(strSQL)
If rstEnc.RecordCount > 0 And Not IsNull(Forms![Encyclopedia Namadan]![Ref]) Then
rstEnc.MoveFirst
Do Until rstEnc.EOF
Call AddReferance(Forms![Encyclopedia Namadan]![EncID], sRef, extract)
rstEnc.MoveNext
Loop
End If
rstEnc.Close
dbs.Close
end sub
Private Sub AddReferences(....)
Set dbs = CurrentDb
Set rstRefs = dbs.OpenRecordset("References", dbOpenDynaset)
rstRefs.AddNew
rstRefs!EncID = EncID
rstRefs!EncRef = EncRef
rstRefs!extract = extract
...
rstrefs.update
etc
End Sub