Updating Data Between Form Controls

kevsim

Registered User.
Local time
, 10:44
Joined
Aug 10, 2002
Messages
34
I have 2 forms, Form “A” and Form “B”. I Update data in Form “A” while Form “B” is closed, when I open Form “B” all the updated data is in the controls. If I try to update the data in Form “A” while Form “B” is open, the data does not appear in the controls of Form “B”. I add the following code in form “A”
Private Sub Form_AfterUpdate()
Forms![F_SearchParts]![Combo10].Requery
Forms![F_SearchParts]![Combo14].Requery
Forms![F_SearchParts]![Combo16].Requery
Forms![F_SearchParts]![Combo20].Requery
End Sub
While both forms are open Form “B” updates OK. Now if I try to update Form “A” with Form “B” closed, I receive an error message because I have not opened Form “B”, I can overcome this by opening Form “B” using code then not making the form visible. My question- “Is there a way to update Form “B” no matter if it is open or closed.” I would appreciate any advise.
kevsim
 
You can use IsLoaded(), came wth Northwind.mdb, to check if form B is loaded or not.

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

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

End Function

Private Sub Form_AfterUpdate()
If IsLoaded("F_SearchParts") = True Then
Forms![F_SearchParts]![Combo10].Requery
Forms![F_SearchParts]![Combo14].Requery
Forms![F_SearchParts]![Combo16].Requery
Forms![F_SearchParts]![Combo20].Requery
End If
End Sub
 
Tim K. said:
You can use IsLoaded(), came wth Northwind.mdb, to check if form B is loaded or not.

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

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

End Function

Private Sub Form_AfterUpdate()
If IsLoaded("F_SearchParts") = True Then
Forms![F_SearchParts]![Combo10].Requery
Forms![F_SearchParts]![Combo14].Requery
Forms![F_SearchParts]![Combo16].Requery
Forms![F_SearchParts]![Combo20].Requery
End If
End Sub
;)
 

Users who are viewing this thread

Back
Top Bottom