colossalUW
Technical User
Hello,
I've created a form to search for a particular grant proposal. The form contains several combo boxes (for grant number, PI ID, and Type) with which the user can narrow the search. A list box (lstSearch) appears at the bottom which displays the search results after "OK" is clicked.
My problem is that data displayed in the list box is not displayed in the same manner as in the combo boxes. For instance, the combo box will show the PI's name (Smith, John), but the list box displays John Smith's ID number, 199456. I realize this is b/c in the PI combo box (cboPIEID), I selected records from tblPIs and chose to only display the last and first name. The list box, however, is populated based on qryGrantsAll, which is in turn based on tblGrants. Also, the field for PI in tblGrants is set as a lookup to tblPIs, but it still display as ID # in lstSearch. How can I have the list box display the name instead of ID number?
Code for running search appears below.
Thanks for any help!
Private Sub cmdOK_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strGC1 As String
Dim strPIEID As String
Dim strType As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryGrantsAll")
If IsNull(cboGC1) Then
strGC1 = " Like '*' "
Else
strGC1 = "='" & Me.[cboGC1].Value & "'"
End If
If IsNull(cboPIEID) Then
strPIEID = " Like '*' "
Else
strPIEID = "='" & Me.[cboPIEID].Value & "'"
End If
If IsNull(cboType) Then
strType = " Like '*' "
Else
strType = "='" & Me.[cboType].Value & "'"
End If
strSQL = "SELECT [tblGrants].* From [tblGrants] WHERE [tblGrants].[GC1#]" & strGC1 & " AND [tblGrants].[PIEID]" & strPIEID & " AND [tblGrants].[GntTypeID]" & strType & " ORDER BY [tblGrants].[GC1#];"
qdf.SQL = strSQL
[lstSearch].RowSource = ""
[lstSearch].RowSource = strSQL
Set qdf = Nothing
Set db = Nothing
End Sub
I've created a form to search for a particular grant proposal. The form contains several combo boxes (for grant number, PI ID, and Type) with which the user can narrow the search. A list box (lstSearch) appears at the bottom which displays the search results after "OK" is clicked.
My problem is that data displayed in the list box is not displayed in the same manner as in the combo boxes. For instance, the combo box will show the PI's name (Smith, John), but the list box displays John Smith's ID number, 199456. I realize this is b/c in the PI combo box (cboPIEID), I selected records from tblPIs and chose to only display the last and first name. The list box, however, is populated based on qryGrantsAll, which is in turn based on tblGrants. Also, the field for PI in tblGrants is set as a lookup to tblPIs, but it still display as ID # in lstSearch. How can I have the list box display the name instead of ID number?
Code for running search appears below.
Thanks for any help!
Private Sub cmdOK_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strGC1 As String
Dim strPIEID As String
Dim strType As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryGrantsAll")
If IsNull(cboGC1) Then
strGC1 = " Like '*' "
Else
strGC1 = "='" & Me.[cboGC1].Value & "'"
End If
If IsNull(cboPIEID) Then
strPIEID = " Like '*' "
Else
strPIEID = "='" & Me.[cboPIEID].Value & "'"
End If
If IsNull(cboType) Then
strType = " Like '*' "
Else
strType = "='" & Me.[cboType].Value & "'"
End If
strSQL = "SELECT [tblGrants].* From [tblGrants] WHERE [tblGrants].[GC1#]" & strGC1 & " AND [tblGrants].[PIEID]" & strPIEID & " AND [tblGrants].[GntTypeID]" & strType & " ORDER BY [tblGrants].[GC1#];"
qdf.SQL = strSQL
[lstSearch].RowSource = ""
[lstSearch].RowSource = strSQL
Set qdf = Nothing
Set db = Nothing
End Sub