HELP !!! Find Record based on input and display in another form.

G

Guest

Hi: Any and all help would be much appreciated. I am a little rusty on
programming................

I have a form called "Search Contracts" with textboxes, a drop down and
check boxes. If the user wants to search a record based on the "Last Name" ,
I want to find that record and display the entire record into another form
called "Search Results". THe form "Search Results" will have text boxes and
check boxes only.

I am at my witts end, I don't know how to capture the record and display
each field into the "Search Results" form.

PLEASE HELP !!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top