TEXTBOX that Searches and Selects from a LISTBOX

Randomblink

The Irreverent Reverend
Local time
Yesterday, 19:16
Joined
Jul 23, 2001
Messages
279
Ok...

I have a form that is linked to a Projects table...
This form jumps from Project to Project and lists out all the pertinent data...

On this form, I have a LISTBOX named: lst_ProjectSearcher

It has a rowsource of:
Code:
SELECT [tbl_ProjectBasics].[Proj_ID], [tbl_ProjectBasics].[Proj_Num], [tbl_ProjectBasics].[Proj_Title] FROM tbl_ProjectBasics WHERE ((Not ([tbl_ProjectBasics].[Proj_Num])="Not Assigned Yet")) ORDER BY [tbl_ProjectBasics].[Proj_Num];
So, this LISTBOX shows ALL the Projects EXCEPT those that have a Project Number that is NOT ASSIGNED YET.

My request is simple...

I have done this in the past, but can't find the database I built that used it... So, here goes...

I want to create a TEXTBOX where the user can start typing a Project Number in it... I want the LISTBOX to jump to the first one that matches...

When you select an object in the LISTBOX it moves the form forward to that Project... So, if let's say we have three Projects in the database... Project Number 10021, 10020, and 10019...

(this is a simple example)

I want that when the user types in 1002 I would like the LISTBOX to JUMP to and show selected PROJECT NUMBER 10020... Since it is SELECTED in the LISTBOX, I want the form to be displaying that project too...

On my LISTBOX, I have the AFTERUPDATE doing this:

Code:
Private Sub lst_ProjectSearcher_AfterUpdate()
lstSearch Me, "Proj_ID", lst_ProjectSearcher
End Sub

Which is calling this FUNCTION:

Code:
Public Function lstSearch(curForm As Form, fldToSearch As String, ctlCriteria As Control, Optional tblSearched As String)
Dim strTableSpecifier As String, strCriteria As String, rst As DAO.Recordset
On Error GoTo Err_lstFindRecord

Select Case tblSearched
    Case Is = "": strTableSpecifier = ""
    Case Is <> "": strTableSpecifier = tblSearched & "]!["
End Select

strCriteria = "[" & strTableSpecifier & fldToSearch & "] = " & Str(ctlCriteria)
    
    Set rst = curForm.Recordset.Clone
    rst.FindFirst strCriteria
    curForm.Bookmark = rst.Bookmark
    rst.Close

Exit_lstFindRecord:
Exit Function

Err_lstFindRecord:
errMessage Err
Resume Exit_lstFindRecord

End Function

Simple...
So, how would I get this to happen? I have created the TEXTBOX and called it txt_SearchBox... What do I do...?

Can you point me to previous posts? I searched and either didn't use the right query string... or they are all deleted... <gasp!>

Help me Mr. Popeil... if you can...
 

Users who are viewing this thread

Back
Top Bottom