G
Greg Snidow
Greetings all. Can anyone help me get this code to work in ADP? I copied it
from an Access tips website and changed the table and field names. It works
in MDB perfectly. In ADP when I hit the cmdUpdateList button nothing happens
at all. I want the list box, lstJobInfo, to populate based on criteria
entered in the various text and combo boxes. If nothing is entered in any of
the boxes I want the update list button to return all records from
tblJobInfo. I realize I posted this same code on Saturday, but it was for a
different problem. Thanks to Brian B. for that help. Thank you in advance.
Private Sub cmdUpdateList_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT tbljob_info.Region, tbljob_info.CO, tbljob_info.RTE,
tbljob_info.[F1/F2], tbljob_info.EWO " & _
"FROM tbljob_info"
strWhere = "WHERE"
strOrder = "ORDER BY tbljob_info.EWO;"
'Set the WHERE clause for the Listbox RowSource if information has been
entered into a field on the form
If Not IsNull(Me.cboRegion) Then '<--If the textbox txtRegion contains no
data THEN do nothing
strWhere = strWhere & " (tbljob_info.Region) Like '*" & Me.cboRegion & "*'
AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.txtCO) Then
strWhere = strWhere & " (tbljob_info.CO) Like '*" & Me.txtCO & "*' AND"
End If
If Not IsNull(Me.txtRTE) Then
strWhere = strWhere & " (tbljob_info.RTE) Like '*" & Me.txtRTE & "*' AND"
End If
If Not IsNull(Me.cboF1F2) Then
strWhere = strWhere & " (tbljob_info.[F1/F2]) Like '*" & Me.cboF1F2 & "*'
AND"
End If
If Not IsNull(Me.txtEWO) Then
strWhere = strWhere & " (tbljob_info.EWO) Like '*" & Me.txtEWO & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.lstJobInfo.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
from an Access tips website and changed the table and field names. It works
in MDB perfectly. In ADP when I hit the cmdUpdateList button nothing happens
at all. I want the list box, lstJobInfo, to populate based on criteria
entered in the various text and combo boxes. If nothing is entered in any of
the boxes I want the update list button to return all records from
tblJobInfo. I realize I posted this same code on Saturday, but it was for a
different problem. Thanks to Brian B. for that help. Thank you in advance.
Private Sub cmdUpdateList_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT tbljob_info.Region, tbljob_info.CO, tbljob_info.RTE,
tbljob_info.[F1/F2], tbljob_info.EWO " & _
"FROM tbljob_info"
strWhere = "WHERE"
strOrder = "ORDER BY tbljob_info.EWO;"
'Set the WHERE clause for the Listbox RowSource if information has been
entered into a field on the form
If Not IsNull(Me.cboRegion) Then '<--If the textbox txtRegion contains no
data THEN do nothing
strWhere = strWhere & " (tbljob_info.Region) Like '*" & Me.cboRegion & "*'
AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.txtCO) Then
strWhere = strWhere & " (tbljob_info.CO) Like '*" & Me.txtCO & "*' AND"
End If
If Not IsNull(Me.txtRTE) Then
strWhere = strWhere & " (tbljob_info.RTE) Like '*" & Me.txtRTE & "*' AND"
End If
If Not IsNull(Me.cboF1F2) Then
strWhere = strWhere & " (tbljob_info.[F1/F2]) Like '*" & Me.cboF1F2 & "*'
AND"
End If
If Not IsNull(Me.txtEWO) Then
strWhere = strWhere & " (tbljob_info.EWO) Like '*" & Me.txtEWO & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.lstJobInfo.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub