PC Review


Reply
Thread Tools Rate Thread

search function using combo list

 
 
datin
Guest
Posts: n/a
 
      24th Sep 2008
hi,
i hv data on staff . when I need to find specific staff, i dont want to
write down the staff ID. I want all staff ID will dispaly in combo list
search.

for current search, i just use the standard code

On Error GoTo Err_search_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_search_Click:
Exit Sub

Err_search_Click:
MsgBox Err.Description
Resume Exit_search_Click

thank you and regards
 
Reply With Quote
 
 
 
 
pietlinden@hotmail.com
Guest
Posts: n/a
 
      24th Sep 2008
On Sep 23, 11:21*pm, datin <da...@discussions.microsoft.com> wrote:
> hi,
> i hv data on staff . when I need to find specific staff, i dont want to
> write down the staff ID. I want all staff ID will dispaly in combo list
> search.
>
> for current search, i just use the standard code
>
> On Error GoTo Err_search_Click
>
> * * Screen.PreviousControl.SetFocus
> * * DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
>
> Exit_search_Click:
> * * Exit Sub
>
> Err_search_Click:
> * * MsgBox Err.Description
> * * Resume Exit_search_Click
>
> thank you and regards


Just use the combobox wizard and select "Find a record..." Set the
source of the combobox to something like

"SELECT ID, LastName & ", " & FirstName As LastFirst FROM Employee
ORDER BY LastName, FirstName;"
 
Reply With Quote
 
 
 
 
datin
Guest
Posts: n/a
 
      25th Sep 2008
thank you. here some code as suggestion

On Error GoTo Err_find_Click

Dim SQL As String
Dim ListForm As Form

Set ListForm = Forms![staff]

SQL = ""

If Not IsNothing(Me![Staff_ID]) Then
SQL = SQL & "[Staff_ID] LIKE '" & Me![Staff_ID] & "*' AND "
End If

If SQL = "" Then
MsgBox "NO STAFF ID SELECTED", 48, "Error"
Exit Sub
End If

If Right$(SQL, 4) = "And " Then
SQL = Mid$(SQL, 1, Len(SQL) - 4)
End If

ListForm.RecordSource = "Select * From staff where " & SQL & ";"

If ListForm.RecordsetClone.RecordCount < 1 Then
MsgBox "The search returned no records." & Chr(13) & " All records
will be displayed.", 48, "FIND PRODUCTION PLAN DATE"
ListForm.RecordSource = "SELECT * FROM staff;"
End If

DoCmd.Close
Exit_find_Click:
Exit Sub

Err_find_Click:
MsgBox Err.Description
Resume Exit_Command5_Click


and use as module:
Option Compare Database 'Use database order for string comparisons
Option Explicit
Function IsNothing(v As Variant) As Integer

' IsNothing starts out as FALSE. We
' determine if v is Nothing by checking
' its VarType

IsNothing = False
Select Case VarType(v)
Case V_EMPTY
IsNothing = True

Case V_NULL
IsNothing = True

Case V_STRING
If Len(v) = 0 Then
IsNothing = True
End If

Case Else
IsNothing = False

End Select

End Function


"(E-Mail Removed)" wrote:

> On Sep 23, 11:21 pm, datin <da...@discussions.microsoft.com> wrote:
> > hi,
> > i hv data on staff . when I need to find specific staff, i dont want to
> > write down the staff ID. I want all staff ID will dispaly in combo list
> > search.
> >
> > for current search, i just use the standard code
> >
> > On Error GoTo Err_search_Click
> >
> > Screen.PreviousControl.SetFocus
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
> >
> > Exit_search_Click:
> > Exit Sub
> >
> > Err_search_Click:
> > MsgBox Err.Description
> > Resume Exit_search_Click
> >
> > thank you and regards

>
> Just use the combobox wizard and select "Find a record..." Set the
> source of the combobox to something like
>
> "SELECT ID, LastName & ", " & FirstName As LastFirst FROM Employee
> ORDER BY LastName, FirstName;"
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
limit the contents of one combo/list box based on what's selected inanother combo/list box CDF Microsoft Access 11 7th Mar 2009 04:23 PM
Using combo boxes to affect the list in another combo box rconnell Microsoft Access Forms 1 27th Sep 2005 02:11 PM
filtering or limiting combo/list box from another combo/list box =?Utf-8?B?am1r?= Microsoft Access Form Coding 20 26th Jan 2005 11:07 PM
Combo/List Box - Trigger secondary List/Combo Box? =?Utf-8?B?RG9yZWVu?= Microsoft Access Form Coding 3 14th Oct 2004 08:05 AM
Text Search: how to search a substring using search companion Search Question Windows XP General 2 23rd Mar 2004 04:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 AM.