Strange behaviour in subform

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:

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
 
Hmm so you have a subform called References and a table called references? Never tried such a construct, but makes me wonder if the db gets confused.

What on earth is " 'Form_References.Form.Requery" Hopefully you dont have a form called that. Form_FormName is normally the name of the class attached to the form, so you should not refer to it, but to the form. In any case, a requery, if called from the parent form, can be:
Me.SubformName.Form.Requery
What is the exact message you get? A verbatim copy please.
 
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.
Did you ever consider the cost of this operation? You need to reconsider your approach or explain to us why you're doing this. Short description please.

Also, like spikepl mentioned, don't use Form_FormName to reference a form.

Then, why on earth would you try to requery a linked subform in the current event of it main form?
 

Users who are viewing this thread

Back
Top Bottom