ltsai
ltsai

Reputation: 757

Microsoft Access Database - Search textbox form

I am trying to create a form which contains a textbox and a button to click on to search for a record in a specific table and show all pertaining information for the searched text. With this form I will be using it as a sub-form so I think VBA is probably the best way.

Here is my Table:

Picture of Table containing data

Here is an example of what I would like to see happen:

Example

I would like to enter a partno and click on the button and the fields will populate.

Please advise how to approach this.

Upvotes: 0

Views: 656

Answers (1)

PaulFrancis
PaulFrancis

Reputation: 5819

On the click of the button you can set the SubForm's Recordsource to be based on the Query. It should be something like.

Private Sub Command0_Click()
    Me!subFrm_searchResult.Form.RecordSource = "SELECT theFields " & _
                                                FROM theTable " & _
                                                WHERE partNoFieldName = '" & 
                                                Me.partNumberTextBoxName & "'"
End Sub

This should be a start for you.

Upvotes: 1

Related Questions