Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60

    "Detail" button on continuous form -- How can I link it to the specific record?

    Hello Wonderful Community!

    I have a continuous form that runs a query to search through contacts and a little other information. Once output, the user will see your typical continuous form with name, and some other detail. I have however, added a 'detail' button to each record. I have this designed to open another form that shows the one to many relationship that each record holds with that table of information.



    My trouble with this, is that I cannot seem to get this form to show the proper records. It simply is stuck showing the first record of the table. This leads me to believe it is a master-child field issue. If anyone has suggestions on how I could perhaps try to find success with my small search database I would greatly appreciate it!

    Sincerely,

    Wesley

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    When you open the form, use a filter which holds the value of the record you are on:
    DoCmd.OpenForm "formname",,"FieldOnNextForm=" & me!FieldOnThisForm
    Add single quotes if it is a text field.

  3. #3
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    The basis of this seems perfect. I just tried however, and I'm still having the same issues. Perhaps there may be another problem.

    DoCmd.OpenForm "sfrm_farm_detail", , "DetailFarmerID=" & Me!ContactFarmerID
    Me.Requery

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sorry, it should be "where", not filter. Add an extra comma after form name.

  5. #5
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    I believe I have it functionally working now. I am having a parameter issue though. It can't seem to find the field on my form..any suggestions?

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Which field are you using? Generally it is the PK for the second form, which is a field on the first form.

  7. #7
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    This is the case with me, PK in second form with secondary key in main.

    However, I am record sourcing the second form directly from the table. Could this be the source of my issue possibly?

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I assume you mean that the second form has the same record source as the main form? No, that is not a problem.

    Can you see the field that you are using to open the second form? I guess not - " It can't seem to find the field on my form". Maybe you can explain this further? If you can see it and the button that you click is on the same row then this wouldn't happen.

  9. #9
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Currently the main form has a record source from a query, that sources from a contacts table and another table including other data. The second form record sources directly from another table. This table contains the DetailFarmerID that is linked to the FarmerContactID which is contained in a table included in the query for the first form.

    My biggest confusion is that these functions are not being recognized at all, which is why I said it couldn't seem to find the field on the form.

    Oh it's always the little things in Access that cause the most grief..

    Could you please explain more into "If you can see it and the button that you click is on the same row then this wouldn't happen."

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sure is confusing - and frustrating! OK, so you have a continuous form with multiple records. On each record of that form you have a button which says open another form and show me the details of this particular record. When you click that button it should open the second form and show that record, which is where we added that to the OpenForm statement: the form's record source is changed by Access to show the first record where that WHERE is true, in this case it will show the first record on the record source table that matches the DetailFarmerID (same as ContactFarmID in the first form's record source).

  11. #11
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    That is precisely what is happening! And it works for the first contact perfectly. I just don't see why it will not follow suit throughout the rest of the records, as they all have their own unique ContactFarmID.

    Would inputting the DoCmd.OpenForm "sfrm_farm_detail", , "DetailFarmerID=" & Me!ContactFarmerID into the macro builder's "where" clause possibly give a different result?

  12. #12
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Where's the third comma?

  13. #13
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Ah I forgot the third comma! I am getting an error now, but I believe I am very close.
    Here is the VBA i'm using

    Private Sub Command77_Click()
    DoCmd.OpenForm "sfrm_farm_detail", , , "FarmerID = " & Me!DetailFarmerID
    End Sub

  14. #14
    WesHarding is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    60
    Unfortunatly, now I recieve an error stating " Microscoft Access can't find the field "DetailFarmerID" referred in your expression"

  15. #15
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Clue on the error?

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

Similar Threads

  1. Replies: 1
    Last Post: 11-17-2016, 10:55 AM
  2. Replies: 11
    Last Post: 02-22-2015, 01:25 PM
  3. Replies: 1
    Last Post: 02-05-2015, 05:41 PM
  4. Command button "Detail for specific entry"
    By Daimios in forum Reports
    Replies: 10
    Last Post: 05-26-2013, 03:46 PM
  5. Replies: 10
    Last Post: 03-15-2013, 05:46 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