Results 1 to 6 of 6
  1. #1
    dinoliciouz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    3

    Open a Form by clicking a record in a Subform in a Main Form

    Hi guys. I'm a newbie in MS Access. I only have very basic knowledge in micros. So my database is like:

    Main Form: Document Detail
    Subform: Document History
    Other Form: Request for Document Change


    All form has the same primary key "RequestID" as they are all created from the same Table:Request.

    What I'm trying to do: When clicking a record in the Subform, the Other Form is opened.

    In the RequestID OnClick properties of the Subform, I use the OpenForm action and set the Where Condition to:
    [RequestID]=[Forms]![Document History]![RequestID]

    Problem:
    - When clicking a record in the Subform on the Main Form, the Other Form won't open. I'll get a popup "Enter Parameter Value".
    - However, if I open the Subform alone and click on any record, it opens the Other Form and displays the specific record.

    Please help. Thanks very much.

  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    When opened as a subform, the form is not a part of the Forms collection. So [Forms]![Document History] is undefined. When opened stand-alone, it IS a part of the Forms collection, so the code works.

    Try this as the Where condition in your DoCmd.OpenForm statement (assuming that RequestID is numeric):

    "[RequestID]= " & Me![RequestID]

  3. #3
    dinoliciouz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    3
    Hi pdebaets,

    Below is my code:

    Private Sub RequestID_Click()
    DoCmd.OpenForm "Request for Document Change", acNormal, , "[RequestID]= " & Me![RequestID], acFormReadOnly

    End Sub


    Now when I click on any record in the Subform - whether standalone or embedded in the Main Form - nothing happens!

    What gives?

    Quote Originally Posted by pdebaets View Post
    When opened as a subform, the form is not a part of the Forms collection. So [Forms]![Document History] is undefined. When opened stand-alone, it IS a part of the Forms collection, so the code works.

    Try this as the Where condition in your DoCmd.OpenForm statement (assuming that RequestID is numeric):

    "[RequestID]= " & Me![RequestID]

  4. #4
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Are you clicking on the RequestID control?

  5. #5
    dinoliciouz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    3
    I'm clicking on a record in the RequestID column in the Subform.

  6. #6
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Put a

    MsgBox "Hi"

    ... statement just before your DoCmd.Openform method to see if the event procedure is being executed.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 10-05-2011, 01:28 PM
  2. Replies: 2
    Last Post: 08-11-2011, 10:02 AM
  3. subform to open form w/ active master record
    By spitfire122 in forum Access
    Replies: 1
    Last Post: 06-28-2011, 04:28 PM
  4. Replies: 1
    Last Post: 11-30-2010, 10:05 AM
  5. Replies: 1
    Last Post: 10-13-2010, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums