MajP
You've got your good things, and you've got mine.
- Local time
- Yesterday, 20:49
- Joined
- May 21, 2018
- Messages
- 8,528
a custom event makes it easier to see how it works. In the called form I put a combobox with choices red, white, blue. It raises and event when the color changes and passes the color.Got it. The "announcement" analogy in order to "handle" (which I read about earlier) works for me.
Code:
Option Compare Database
Option Explicit
'Called Form
Public Event ColorChange(Color As String)
Private Sub cmboColor_AfterUpdate()
RaiseEvent ColorChange(Me.cmboColor)
End Sub
The calling form will change color whenever the called form raises the event.
Option Compare Database
Option Explicit
Code:
'Code in frmCalling
Public WithEvents myFrm As Form_frmCalled
Private Sub Command1_Click()
DoCmd.OpenForm "frmCalled"
Set myFrm = Forms("frmCalled")
End Sub
Private Sub myFrm_ColorChange(Color As String)
If Color = "red" Then Me.Detail.BackColor = vbRed
If Color = "blue" Then Me.Detail.BackColor = vbBlue
If Color = "white" Then Me.Detail.BackColor = vbWhite
End Sub
The called form knows nothing about which form called it or which event handler traps the event.