Hi, Josephine.
I don't know how to capture the record and display
each field into the "Search Results" form.
Create a query that includes all of the fields that will be displayed in the
"Search Results" form. Use the Form Wizard to create the "Search Results"
form using this query as the data source.
Create a query that lists the names and primary key of the table. For
example:
SELECT PID, (FirstName & " " & LastName) AS FullName
FROM tblPersonnel
ORDER BY LastName, FirstName;
.. . . where PID is the primary key of the tblPersonnel table. Save this
query and name it qryFullNames.
In the combo box properties of the Search Contracts form, select the "Data"
tab and assign qryFullNames as the Row Source Property. Select the "Format"
tab and select the Column Count Property. Type 2 as the property. Select
the Column Widths Property and type:
0";1"
.. . . so that the first column will be hidden. Create an OnAfterUpdate( )
event for this combo box. For example:
Private Sub cboNames_AfterUpdate()
On Error GoTo ErrHandler
DoCmd.OpenForm "Search Results", , , "PID = " & Me!cboNames
Exit Sub
ErrHandler:
MsgBox "Error in cboNames_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
End Sub
.. . . where Search Results is the name of the form, cboNames is the name of
the combo box, and the primary key of the table table that the Search Results
form is bound to is named PID. Save and compile the code. Close the
Properties dialog window and save the form.
Open the form in Form View and select a name in the combo box. The name
selected will be the record that the Search Results form will display.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.