Full Version: Link summary subform to detail subform
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
JohnnyB
Hello Everybody,

I have a form with three subforms (picture attached). Two subforms show lists of records, one where a field is null, the other where the field is not null. The third subform shows the detail for one record. They all have the same key field. The list subforms only show the key field and one other bit of identifying info. I want to be able to double click the key field of a subform and have the detail show up in the detail subform to the right of the list subforms, not in a separate form. It should almost work like a web page where you click a link on the side and the detail shows up in the main part of the page. I have the three forms, they're just not linked.

Any ideas?

Thanks,
Zavenstar
Hi

Overview
-Use the double Click event of the Key control in the 2nd subform
- Reset the Recordsource of the Detail 3rd subform
- use the key from the 2nd form in a query to set the record source

Use this untried code with made up names as an example

CODE


Private Sub txtKey_DblClick(Cancel As Integer)

Dim C as Control    

On Error GoTo txtKey_DblClick_Err

Set C = Forms!DetailSubform

C.Form.RecordSource = "SELECT Table.* FROM Table WHERE Key = "  &  LTrim(str(Me!Key)) & ";"

Set C = Nothing

txtKey_DblClick_Exit:
      
Exit Sub

txtKey_DblClick_Err:
    
MsgBox "Error in [txtKey_DblClick]! Error = " & Err.Number & Space(2) & Err.description
Resume txtKey_DblClick_Exit

End Sub


Z
JohnnyB
Z,

Thanks, but I came up with a different solution. I changed the two smaller subforms with the lists to listboxes and created two detail subforms that are exactly the same size. One subform shows the detail for an item in the top listbox, the other for the lower. Both are invisible when the form opens. If you double click a record in the top listbox, the detail for that one becomes visible, the detail for the lower one becomes invisible and the whole form refreshes. If the bottom listbox is clicked the subform for that one becomes visible, the other one invisible and the form refreshes. That seems to work also so I'll stick with that for now. If I have problems, I'll give yours a try.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.