List Box Search Help

Charmed7

Registered User.
Local time
Today, 08:19
Joined
Jul 23, 2004
Messages
53
I'm hoping not to make this vague, but I don't know where to start.

-I got some programing from a db that someone posted, a looooonnnngggg time ago. It is a search box, I type all or part of the file number and a list of matching files show in a list box. When I double click the item in the list box, it opens the form with that record showing.

Everything was going great for years...and now it doesn't. :(

Here is the code from the list box (maybe the author will recognize it and can help)
________________________________________________________
Option Compare Database

Private Sub cmdSearch_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 qry_QCOpenOrders.Policy_Number " & _
"FROM qry_QCOpenOrders"

strWhere = "WHERE"

strOrder = "ORDER BY qry_QCOpenOrders.Policy_Number;"


'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.txtPolicyNumber) Then '<--If the textbox txtPolicyNumber contains no data THEN do nothing
strWhere = strWhere & " (qry_QCOpenOrders.Policy_Number) Like '*" & Me.txtPolicyNumber & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
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.PolicyInfo.RowSource = strSQL & " " & strWhere & "" & strOrder

End Sub






Private Sub PolicyInfo_DblClick(Cancel As Integer)
On Error GoTo Err_PolicyInfo_DblClick

Me.Visible = False
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_QualityControl"

stLinkCriteria = "[Policy_Number]=" & "'" & Me![PolicyInfo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_PolicyInfo_DblClick:
Exit Sub

Err_PolicyInfo_DblClick:
MsgBox Err.Description
Resume Exit_PolicyInfo_DblClick
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click


DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub

Private Sub PolicyInfo_LostFocus()

Me.Refresh

End Sub
______________________________________________________
I dunno why it's not going through any more. Anyone with direction, help or just a flat out answer please please shine your knowledge onto my dark dark world.

Thanks in advance. I'll keep you posted if I stumble upon something.
 

Users who are viewing this thread

Back
Top Bottom