Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: List Box Query


Message #1 by "KennethMungwira" <KennethMungwira@y...> on Fri, 28 Feb 2003 16:15:24
Dear Helper,

I have a table which has a lot of information in it, so I created a list 
box to scroll through all the information. I have a List box and two 
combo boxes which I would like to use to search for items in the the list 
box. 
Narrow search using "From" and "FrName", the code I wrote will not work 
can anyone help...(Please)

Option Compare Database

Option Explicit
Private Const strSQL1 = "SELECT [LineSeg Data].*" & "where From='"
'Private Const strSQL1 = "Select [LineSeg Data]" & " qryCombo1 Where 
From='"

Private Const strSQL2 = "' And FrName="

Private strSQL As String

Private Const strMsg1 = " Select From list"
Private Const strMsg2 = " Select FromName list"

Private Sub cboFrName_BeforeUpdate(Cancel As Integer)
    If Me!cboFrom.Value <> "" Then
        Call FillList
    Else
        Msg = strMsg2
        'Me!lblList.Caption = strMsg2
    End If
End Sub

Private Sub cboFrom_AfterUpdate()
    If Me!cboFrName.Value > 0 Then
        Call FillList
    Else
        Msg = strMsg1
        'Me!lblList.Caption = strMsg1
    End If
End Sub

Private Sub FillList()
    strSQL = strSQL1 & Me!cboFrom.Value & strSQL2 & Me!cboFrName.Value
    '[Forms]![NewXfrmr]![lstSource].RowSource = strSQL
    '[Forms]![NewXfrmr]![txtTName].SetFocus
    [Forms]![2002]!lblList.RowSource = strSQL
    [Forms]![2002]!lblList.Requery
    'Me!lblList.Caption = "From" & Me!cboFrom.Value & "For" & Me!
cboFrName.Column(1)
    
    'If [Forms]![2002].ListCount = 0 Then
       ' Me!lblList.Caption = "No" & Me!lblList.Caption
   ' End If
    
End Sub

Private Sub Form_Activate()
    If Me!cboFrom.Value <> "" And Me!cboFrName.Value > 0 Then
        Call FillList
    Else
        Msg = strMsg1
        'Me!lblList.Caption = strMsg1
    End If
End Sub



  Return to Index