Updating Data Between Form Controls (1 Viewer)

kevsim

Registered User.
Local time
Today, 14:14
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
 

Tim K.

Registered User.
Local time
Today, 05:14
Joined
Aug 1, 2002
Messages
242
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
 

kevsim

Registered User.
Local time
Today, 14:14
Joined
Aug 10, 2002
Messages
34
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

Top Bottom