5 pts.
 Access 2007: VB code to make a button press link to a specific record in another form
The database is for a set of components. One of my forms shows details about each component on a separate record (the property "Default View" is Single Form). The other form is a list of all components by component number displayed all together (the property "Default View" is Continuous Forms). The list of components has a button next to each component listed. When this button is clicked, I need the record from the other form that contains the details to the respective component to come up. What code will I need to write for the buttons "On Click" event to make this happen? Thanks!

Software/Hardware used:
ASKED: May 11, 2009  9:59 PM
UPDATED: November 25, 2011  10:14 AM

Answer Wiki:
On your listing form, have the button run the OpenForm method. In the detail form, have the Form_Open event either set the filter property or set the RecordSource property. Using the Filter property: Sub Form_open me.filter = "Component = " & Forms![ListingForm]![Component] me.filteron = true End Sub With the filter, the user could remove the filter so all components would appear. To avoid that, set the RecordSource property: Sub Form_Open Me.RecordSource = "Select * from DetailTable Where Component = " & Forms![ListingForm]![Component] End Sub For either option, if the component is alphanumeric, you must include ' (single quote) in the string. "Component = '" & Forms![ListingForm]![Component] & "'"
Last Wiki Answer Submitted:  May 12, 2009  3:31 pm  by  Randym   1,740 pts.
All Answer Wiki Contributors:  Randym   1,740 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _