简体   繁体   中英

in access need to doubleclick on record in subform to show detail on main form

I have a main form with a subform. The subform is continuous and shows all of the records. The main form works great for adding and editing records. I need to be able to double click on a record in the subform and that record be displayed on the main form for editing.

By experience I reccomend you to achieve what you are trying by placing two subforms into the master one. In one you have the list and in the other the details.

In the master form you place a hidden link field that is populated when you doubleclik on the list.

This field, let´s call it [link] is the Link Master Field in the detail subform, and the Link Child Field is the id (primary key) to identify your selection.

This will link your double click (or simple) with showing the details.

I found a solution that works to move to display the record from the subform in the master for editing.

In the DblClick event on the subform I put in the following code:

Let Forms!FrmNotes.CboNotesID = TxtNotesID 'TxtNotesID is the ID on the subform

Call Me.Parent.DisplayRecord

On the main for I created

Public Sub DisplayRecord()

CboNotesID.SetFocus

DoCmd.SearchForRecord , "", acFirst, "[NotesID] = " & "'" & Screen.ActiveControl & "'"

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM