jbakestull
asked on
Access 2007 List box with multiple columns where each column has its own SQL query
I'm not that experience working/understanding list boxes. Was wondering if a list box column can have its own separate query?
The syntax code below looks up "Eligibility" and "Subsidy" values based off client id. The two values "Eligibility" and "Subsidy" are matched up against another table to populate "provider Id" that matched. The reason why I would like to use separate queries for each column is to add additional information like occupancy, availability etc. All this information is located on different tables.
The syntax code below looks up "Eligibility" and "Subsidy" values based off client id. The two values "Eligibility" and "Subsidy" are matched up against another table to populate "provider Id" that matched. The reason why I would like to use separate queries for each column is to add additional information like occupancy, availability etc. All this information is located on different tables.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim tblRst As DAO.Recordset
Dim strSql As String
Dim vcatch As String
Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
Dim strSql2 As String
strSql = "Select * from tblFamilyCharac Where [strClientId] = '" & Me.txtsearch & "'"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSql, dbOpenDynaset)
If Not (rst.BOF And rst.EOF) Then
rst.MoveFirst
Do While Not rst.EOF
With Me
.cboElibility = rst!cboElibility
.cboRebulidingLives = rst!cboRebulidingLives
End With
rst.MoveNext
Loop
rst.Close
Me.txtsearch.SetFocus
End If
If IsNull(Me.txtsearch) = True Then
MsgBox "Please entered a client ID", vbOKOnly
Exit Sub
Else
' Loading list box choices based off client elibility and rebuilding lives values
strSql2 = "SELECT strProviderName As Provider FROM tblEligibilityCharacteristics WHERE intRebuildingLives='" & Me.cboElibility & "' AND strSubsidy='" & Me.cboRebulidingLives & "'"
vcatch = strSql2
Me.txtlist.RowSource = vcatch
Set db1 = CurrentDb
Set rst1 = db.OpenRecordset(strSql2, dbOpenDynaset)
If Not (rst1.EOF And rst1.BOF) Then
'display your records
'........................
Else ' if no records found
MsgBox "No records found!", vbOKOnly
End If
End If
Set rst = Nothing
Set db = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not really. A single query (possibly multiple tables) can be the Row Source for a List box)
mx