Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    21

    Unanswered: OpenArgs question

    I use the "DoCmd.OpenForm stDocName, , , stLinkCriteria, , , JobID & ProjectName" to open a form with the parameters passed in OpenArgs variable. The OpenArgs variable contains the expected data. Then later in the program run, I want to open the form with a different "JobID". When I call the DoCmd.OpenForm.... command (same as above, except with a different Job ID), I don't get the expected data. I get the previous OpenArgs data.

    Example: I call DoCmd.OpenForm with OpenArgs = "TP01", the form opens and I display me.openargs in a message box (it displays "TP01"). When I call DoCmd.OpenForm with OpenArgs = "TP02" and display it in the msgbox, I get "TP01" again. It should be TP02.

    I tried calling DoCmd.close but that makes no difference. Does anyone know what I am doing wrong when I use the OpenArgs property?

    TIA,
    flynn

  2. #2
    Join Date
    Sep 2002
    Location
    Coventry, Warwickshire, UK
    Posts
    74
    It worked OK for me when I tested it, thus

    Sub Test()

    DoCmd.OpenForm "Form1", acNormal, , , , , "Args1"
    DoCmd.Close acForm, "Form1"
    DoCmd.OpenForm "Form1", acNormal, , , , , "Args2"
    DoCmd.Close acForm, "Form1"

    End Sub

    Private Sub Form_Load()
    Debug.Print Me.OpenArgs
    End Sub

    Result:

    Args1
    Args2
    Roger Hampson
    XI - ecs (UK) Ltd

  3. #3
    Join Date
    Sep 2002
    Posts
    21
    Thank you xiecsuk,

    You gave me the answer. I wasn't specifying the form name on the DoCmd.Close call. So I wasn't closing the form, but the next DoCmd.OpenForm call filled in the correct data except for the OpenArgs property.

Posting Permissions

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