1

This seems like a really simple thing to do, and I believe I'm coding it correctly - but I get me.openargs as NULL for some reason.

Calling code in a button click event on form1:

Private Sub Command0_Click()

    DoCmd.OpenForm "frmGetLetter", , , , , , "CA14-09"

End Sub

Form Open event on the called code:

Private Sub Form_Open(Cancel As Integer)

If Not IsNull(Me.OpenArgs) Then
    strLetterName = Me.OpenArgs
Else
    strLetterName = "MISC-02"
End If

me.Openargs is always NULL - what am I missing here?

  • 1
    Are you making sure the form is closed before this is called? – Erik A Apr 08 '20 at 13:21
  • Try `Form_Load()` instead. – Kostas K. Apr 08 '20 at 14:56
  • Both Open and Load events work for me. If form 2 is already open, OpenForm command will execute but OpenArgs will not be populated and Load and Open events do not execute anyway. – June7 Apr 08 '20 at 15:43
  • I wasn't able to replicate the problem; your code works on my machine. I suggest the microsoft fix of rebuilding the forms from scratch. – mazoula Apr 08 '20 at 17:47
  • Thank you for the answers Erik A and June7, the issue was that I already had the form open when I was calling it! I did not know of that quirk. – Andrew Jennings Apr 08 '20 at 19:08

1 Answers1

0

As Erik A and June7 suspected, I had the form I was calling already open. Everything works as expected if I DoCmd.Openform without it being opened previously.

Many thanks!