Access 2007: VB code to make a button press link to a specific record in another form

5 pts.
Tags:
Access 2007 forms
Access VBA
Microsoft Access
Microsoft Access 2007
VBA
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!

Answer Wiki

Thanks. We'll let you know when a new response is added.

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] & “‘”

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following