Something simple - Refresh problems

Richio

Registered User.
Local time
Today, 13:23
Joined
May 31, 2002
Messages
75
I have a main form which displays summary data and another form to enter data.

It is set up so when the data entry form closed the main form is updated immediately (only displaying info for that record ...but I don't think that has anything to do with my problem)

I have done this by entering

Forms!name of main form.Refresh on the after update section of the data entry form.

It works fine.......but......if you close the main form accidently with the data entry form still open and then try and close the data entry form it "debugs" into visual basic as it cannot find the main form to Refresh.

Is there a way round this......I am thinking along the lines of some sort of "only refresh if the form is open" but have no idea how to do this

Please help....I am becoming frustrated
 
There is most probably a more direct way, but you could try this. It loops through the open forms and returns the names of all open forms

dim frm as Form
For Each frm In Forms
If frm.Name = "MainFormName" then
Forms!MainFormName.Refresh
End if
Next frm


HTH
 
I had a similar problem (was getting Debug error message too) and Pat told me to use .Requery instead of .Refresh, which did work.

HTH
 
There is an IsLoaded property you can reference in Access2000, or use this function:


Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is loaded.

Const conDesignView = 0
Const conObjStateClosed = 0

IsLoaded = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
 
Thanks

Have tried the Requery which although works creates other problems as I am running subforms and tabbed pages - the requery does updtae but takes me out of the "current view" I am in.

I will have a go at the other options suggested ...
 
Harry

Works spot on........much appreciated
 

Users who are viewing this thread

Back
Top Bottom