Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Queries and Primary Key Fields

Status
Not open for further replies.

AWilliams

Programmer
Mar 20, 2002
10
CA
I have a search form (main from) containing a combo box from which a user can select one of two service request types to do seraches on. Each service request type calls its own query to populate a subform with five fields of data captured from the appropriate table.

The queries work fine and bring back the associated records from the tables. But when I add the primary key field to the queries, they return only the first record in the table.

The funny thing is the queries work fine in design view but not in the search form. Any Suggestions to what may be happening?

Here's some of the code I used in the serach event of the form:

Code:
If Me.cboServReqType.Value = 166 Then
        
Me.Form.RecordSource = "tbLingSuppServ"
Me.SubformA.Form.RecordSource = "qryLingSuppSearch"
Me.SubformA.Form.txtRequestNum.ControlSource = "LS_RequestNum"
Me.SubformA.Form.txtRequestDate.ControlSource = "LS_RequestDate"
Me.SubformA.Form.txtRequestStatus.ControlSource = "LS_RequestStatus"
Me.SubformA.Form.txtDeptAgency.ControlSource = "LS_DeptAgency"
Me.SubformA.Form.txtContactName.ControlSource = "LS_ContactName"
Me.SubformA.Form.txtContactPhone.ControlSource = "LS_ContactPhone"
Me.SubformA.Form.txtID.ControlSource = "CT_tbCodeTable_ID"
Me.SubformA.Form.txtID.ControlSource = "LS_tbCodeTable_ID"
Me.SubformA.Form.txtTableID.ControlSource = "LS_tbLingServ_ID"

End If

 
I am a little surprised. Primary keys and other indexes work on tables, not queries. Queries use indexes (of which the primary key is one) to help searching and sorting.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top