-1

I am trying to open a form as a dialog and also pass a string in the OpenArgs property. No matter what I try, I get an Invalid use of null error.

The form is not open. It's not open in design mode either. Can anyone shed some light on this for me?

Here's the calling line:

DoCmd.OpenForm strTmpForm, acNormal, , , , acDialog, "Hi"

Here's the Form Open Sub on the target form

Private Sub Form_Open(Cancel As Integer)
    MsgBox Me.OpenArgs
End Sub
Erik A
  • 31,639
  • 12
  • 42
  • 67
MultiGuy
  • 912
  • 2
  • 17
  • 34
  • May be there is another error like a data error. Does the form work correctly if you use MsgBox Nz(Me.OpenArgs)? – Olivier Jacot-Descombes Nov 11 '11 at 22:49
  • Some info here: http://www.accessmonster.com/Uwe/Forum.aspx/access-forms/50466/OpenArgs-yawn-yawn This seems to be an unreliable way to pass info to a form. You might be better off creating a property on the form, and setting that before showing it. – Tim Williams Nov 11 '11 at 22:59
  • Possible duplicate of http://stackoverflow.com/questions/258556/openargs-is-null-error – Adam Lear Nov 23 '11 at 03:01

1 Answers1

1

Are you sure the form isn't open and hidden? It seems likely, since the usual dialog pattern usually involves hiding the dialog form to allow control to resume in the calling method.

To be certain:

If SysCmd(acSysCmdGetObjectState, acForm, strTmpForm) <> 0 Then
    DoCmd.Close acForm, strTmpForm
End If

If that's not the problem then I'd ask if you can post the entire calling method rather than the calling line.

phoog
  • 42,068
  • 6
  • 79
  • 117
  • YAY!!!! Between Oliver and Phoog, you've SAVED ME!!!! I've been messing with this ALL DAY. I had been closing the form, so I still don't think that was the problem. I did add the your 'If SysCmd...' logic just in case. But I think it was the NZ() function that really made a difference. Don't know why that works, but it does! Thank you , thank you, thank you.... – MultiGuy Nov 11 '11 at 23:50