Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Thanked 0 Times in 0 Posts

    Parsing String (2003)

    Hans was kind enough to assist me in finding a solution to pass a form field to another form. I now need to pass an additional form field to the new field. I setup a string (I guess that's the best way)? Now, I can't figure out how to parse it. Here is my code at the moment....

    On main form

    Private Sub Add_Comment_Click()
    DoCmd.OpenForm FormName:="Add Comments", DataMode:=acFormAdd, OpenArgs:=Me.Owner & "," & Unit
    End Sub

    Then in the form which will display the passed values:
    Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then
    Me.Owner.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    Me.Unit.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End If
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Parsing String (2003)


    Me.Owner.DefaultValue = Chr(34) & Left(Me.OpenArgs, InStr(Me.OpenArgs, ",") - 1) & Chr(34)
    Me.Unit.DefaultValue = Chr(34) & Mid(Me.OpenArgs, InStr(Me.OpenArgs, ",") + 1) & Chr(34)

    The InStr function determines the position of the comma in OpenArgs, and the Left and Mid functions are used to extract the part before and after the comma.

Posting Permissions

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