Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004

    Unanswered: OpenArgs for a report

    I'm trying to use OpenArgs within the OpenReport method

    In response to a click event I have:

    DoCmd.OpenReport "rptConsumer", acViewPreview, , , acWindowNormal, "" & strTicketNumber & ""

    The code compiles and if I hover over the strTicketNumber variable it has a value.

    At the report itself on the Form_Open event I have:

    strTicketNumber = Me.OpenArgs

    The Me.OpenArgs is coming up as Null. I tried Reports!rptConsumer.OpenArgs and I get the same thing...Null.

    Like it's not coming over.

    I've done this many times with forms without a problem. This is the first time I've tried it on a report.

    Any ideas?

  2. #2
    Join Date
    Nov 2003
    If strTicketNumber is indeed a String variable as the name migh suggest, then your string should be passed to the report form (the double quotes are not needed either).

    The Call:
    Dim strTicketNumber As String
    strTicketNumber = "This Is A TEST!"
    DoCmd.OpenReport "rptConsumer", acViewPreview, , , acWindowNormal, strTicketNumber
    This should pass the string "This Is A TEST!" to the Report through OpenArgs.

    In The Report OnOpen event:
    Dim strTicketNumber As String
    strTicketNumber = Me.OpenArgs
    MsgBox strTicketNumber
    This should display a MsgBox that states "This Is A TEXT!" before the report is visible.

    Self Taught In ALL Environments.....And It Shows!

  3. #3
    Join Date
    Jul 2010

    Make sure the report is closed

    I know this is an old thread but this is something I ran into a few times, so figure having a correct answer will help those googling for this.

    If the report (or form) is open (i.e. being edited) when you try to open it from code, the OpenArgs registered will be Null rather than the argument you're trying to send.

  4. #4
    Join Date
    Feb 2007
    Not sure why the fuss about responding to old posts as this one gave me the answer I needed on the first google listing so thanks!

  5. #5
    Join Date
    Nov 2013


    Got to agree with WannaKatana. Old treads often solve new problems.

    I would add an additional observation for Access 2003, OpenArgs can be used directly on the ControlSource property, but it appears only if you have also used it in the Open event.

    Private Sub Report_Open(Cancel As Integer)
    Dim stringval As String
    stringval = Me.OpenArgs
    End Sub

    Without this openargs seems to return a blank value, not a null.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts