Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239

    Open form on selected record - continous subform ?

    Hi,

    I have a form with continous subform, for which I had added custom right-click context menu.



    In this context menu I'm opening 2nd form (with subform also). That form should open in same record as I right-clicked the menu in field of previous form. Context menu is set for text field in continous subform.

    This doesn't work, since code for opening form is launched from a module and not from 1st form Itself - so Me! can't work :

    Code:
    DoCmd.OpenForm "YourFormName", , , "[NameOfFieldFromDataSource]='" & Me![NameOfFieldOnFormOpeningFrom] & "'"
    What can I do to fix this ??

    I'm really struggling with this one, any help much appreciated !!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    I had, but this doesn't work also:

    Code:
    DoCmd.OpenForm ""2ndForm",  , , "[FieldName] =' " & Forms![1stForm]![1stFormSubform].Form![SubformField] & " ' "
    I think problem is bigger....Just don't know where to start

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For starters try without the spaces:

    DoCmd.OpenForm ""2ndForm", , , "[FieldName] ='" & Forms![1stForm]![1stFormSubform].Form![SubformField] & "'"

    Presumably you put the actual names in?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Presumably you put the actual names in?
    Yes I do with actual names, and with no spaces too, I did space here just to see all characters. And this posted code doesn't also solve the selected current record in continous form, I need something like CurrentRecord property, Me! is not working from module.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    I will make example DB, give me 15 minutes. Can't post real one, job application

  8. #8
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Ok,

    I have made a sample. Sorry for waiting, couldn't done It so fast. I hope I didn't miss anything....

    Instructions:

    Open "Form1" - right click on any field in record (continous form). You'll see context menu for opening second form - this is not working !!

    disregard code error for context menu - If you'll run code twice, just stop It.
    Attached Files Attached Files

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Form1 has no subform. This works:

    DoCmd.OpenForm "Form2", , , "ID_Table1=" & Forms![Form1]![ID_Table1]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    sorrrrryyy, I see now, you're right.

    Take a look at this sample. Same principle, Just open form3. I allready pasted your code in.

    So, Is my design wrong, maybe that's why is not working ??


    EDIT: Everything I did in this sample is that I created new form, and put Form2 in It, as subform.
    Attached Files Attached Files

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    And what is it you want to do? This doesn't have the ID field in it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Yes, this is how I have in my DB. I want to do exactly what you did before.

    Let me explain...In real DB I open "search" form, that's my 1st Form. Based on criteria of User, this form then opens a new form with subform - and displays records that match "search" Form criteria.

    I have context menu in subform there, and with right-click in It should open a new form - this one has on top of form data from matches, and under that a subform from 2nd table that matches this upper record.

    In other words - user searches record, finds It, right-clicks It in continous subform, and new form opens - where he can see what "other Items" are saved to this record (and this other Items are in different table-linked).

    I hope you understand this, I't a little bit complicated...

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I understand conceptually what you want to do. With this sample, when they right click, which form should be opened, and what field's data should be used for matches?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    In this sample: If you open form3, and right-click It, form2 should open, on exatly same record as you clicked in Form3.

    You can see desired output, If you just open form2, without doing anything before, that's why I left record selectors on form, I don't have them in my DB.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    DoCmd.OpenForm "Form2", , , "ID_Table1=" & Forms![Form3]!form1.Form![ID_Table1]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Continuous search form won't open selected record in view form.
    By IncidentalProgrammer in forum Programming
    Replies: 20
    Last Post: 03-24-2015, 02:53 PM
  2. Replies: 2
    Last Post: 07-10-2013, 12:01 PM
  3. Replies: 5
    Last Post: 06-19-2013, 08:01 AM
  4. Replies: 3
    Last Post: 09-20-2012, 11:09 AM
  5. Replies: 7
    Last Post: 05-01-2012, 11:43 AM

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