Hi, Fred:
I use your code and got error message saying expression not found and it
pointed to:
[txtMessage] = Me.OpenArgs
what did I do wrong?
- Song
fredg said:
How to pass fromMSG to txtMSG of frmConfirm? Below is my code:
Private Sub cmdDayOneWinter_Click()
Dim fromMSG As String
fromMSG = "Add Winter to Day One" 'The msg I want to pass to control
of
frmConfirm
DoCmd.OpenForm "frmConfirm", , , , , acDialog
If Forms.frmConfirm.intAnswer = 1 Then
DoCmd.OpenQuery "qryAddDayOneWinter", acNormal, acEdit
End If
End Sub
Use the OpenForm method's OpenArgs argument:
Dim fromMSG As String
fromMSG = "Add Winter to Day One" '
DoCmd.OpenForm "frmConfirm", , , , , acDialog, fromMsg
Then code the frmConfirm Load event:
If Not IsNull(Me.OpenArgs) Then
[txtMessage] = Me.OpenArgs
End If
You did use the frmConfirm Load event for that code, I hope.
Do you have an unbound control named [txtMessage] on the form?
Let's make a test run.
Change the code I gave you to:
Private Sub cmdDayOneWinter_Click()
Dim fromMSG As String
fromMSG = "Add Winter to Day One" '
MsgBox "fromMsg = " & frmMsg
DoCmd.OpenForm "frmConfirm", , , , , acDialog, fromMsg
End if
Code the frmConfirm Load event:
Private Sub Form_Load()
MsgBox "OpenArgs = " & Me.OpenArgs
If Not IsNull(Me.OpenArgs) Then
[txtMessage] = Me.OpenArgs
End If
MsgBox "txtMessage = " & [txtMessage]
End Sub
The above assumes you have an unbound control on "frmConfirm" named
"txtMessage".
You should get one message stating "fromMesg = Add Winter to Day One"
One message stating "OpenArgs = Add Winter to Day One"
One message stating "txtMessage = Add Winter to Day One"
If any of those messages are blank post back.