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

    Form/Macro (2003)

    I have a form where the user can see detailed information about an owner. Well, I'm also displaying comments linked to the specific owner from another table. I have a link on the form to add a new comment. I have an onclick behavior to run a macro to open the comment form. My only problem is... I don't know how to carry over the specific owner id to the comment table. I open the form and I enter my comment, but it's not attached to any owner. Am I making sense?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form/Macro (2003)

    This is best done in VBA.

    1) Use code like the following to open the comment form:

    Private Sub cmdComment_Click()
    DoCmd.OpenForm FormName:="frmComment", DataMode:=acFormAdd, OpenArgs:=Me.ID
    End Sub

    cmdComment = name of command button
    frmComment = name of comment form
    ID = name of owner ID field

    2) Use the On Load event of the comment form to set the default value of the ID field:

    Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then
    Me.ID.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End If
    End Sub

    ID = name of control bound to owner ID field (may be hidden)

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form/Macro (2003)

    Hans,

    I apologize for the delay in my response. Your recommendation worked perfectly. Thanks again for taking the time to help!

    Best regards,
    Muscle

Posting Permissions

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