find record using combo box

I want to use combo box to locate a name. After update, the combo box shows 
the name but the form does not move to the record of combobox. Here is my 
code:

Private Sub cboLook_AfterUpdate()

    Dim rs As DAO.Recordset

        'Search in the clone set.
        Set rs = Me.RecordsetClone
        rs.FindFirst "[name]= """ & Me.cboLook & """"
           'Display the found record in the form.
            Me.Bookmark = rs.Bookmark
            frmFlexSubform.SetFocus
        Set rs = Nothing

End Sub 


0
Song
2/24/2007 2:47:27 AM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
968 Views

Similar Articles

[PageSpeed] 12

You have a field named Name?
Access is very likely to get that confused.
Rename the field in your tables, queries, forms, reports, macros and code.

To test what's going on, try:
    Dim rs As DAO.Recordset
    Dim strWhere as String

    strWhere = "[name]= """ & Me.cboLook & """"
    Debug.Print strWhere

    Set rs = Me.RecordsetClone
    rs.FindFirst strWhere
    If rs.NoMatch Then
        MsgBox "Not Found"
    Else
        me.bookmark = rs.bookmark
    End If
etc
-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Song Su" <csitnnn@hotmail.com> wrote in message
news:OEIfe47VHHA.4668@TK2MSFTNGP04.phx.gbl...
>I want to use combo box to locate a name. After update, the combo box shows 
>the name but the form does not move to the record of combobox. Here is my 
>code:
>
> Private Sub cboLook_AfterUpdate()
>
>    Dim rs As DAO.Recordset
>
>        'Search in the clone set.
>        Set rs = Me.RecordsetClone
>        rs.FindFirst "[name]= """ & Me.cboLook & """"
>           'Display the found record in the form.
>            Me.Bookmark = rs.Bookmark
>            frmFlexSubform.SetFocus
>        Set rs = Nothing
>
> End Sub
> 

0
Allen
2/24/2007 2:57:07 AM
I got 'Not Found' message. Rename [name] would solve it?

"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message 
news:Ojku697VHHA.480@TK2MSFTNGP02.phx.gbl...
> You have a field named Name?
> Access is very likely to get that confused.
> Rename the field in your tables, queries, forms, reports, macros and code.
>
> To test what's going on, try:
>    Dim rs As DAO.Recordset
>    Dim strWhere as String
>
>    strWhere = "[name]= """ & Me.cboLook & """"
>    Debug.Print strWhere
>
>    Set rs = Me.RecordsetClone
>    rs.FindFirst strWhere
>    If rs.NoMatch Then
>        MsgBox "Not Found"
>    Else
>        me.bookmark = rs.bookmark
>    End If
> etc
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Song Su" <csitnnn@hotmail.com> wrote in message
> news:OEIfe47VHHA.4668@TK2MSFTNGP04.phx.gbl...
>>I want to use combo box to locate a name. After update, the combo box 
>>shows the name but the form does not move to the record of combobox. Here 
>>is my code:
>>
>> Private Sub cboLook_AfterUpdate()
>>
>>    Dim rs As DAO.Recordset
>>
>>        'Search in the clone set.
>>        Set rs = Me.RecordsetClone
>>        rs.FindFirst "[name]= """ & Me.cboLook & """"
>>           'Display the found record in the form.
>>            Me.Bookmark = rs.Bookmark
>>            frmFlexSubform.SetFocus
>>        Set rs = Nothing
>>
>> End Sub
>>
> 


0
Song
2/24/2007 3:04:20 AM
I took your advice and change [name] to [full_name]. I also discovered that 
I bounded to wrong column in combo box. Now it's fixed.

I want to set up 2nd combo box to search [EN]. Error message says 'data type 
mismatch'.
My [EN] is numerical field. how do I construct rs.FindFirst line?

Thanks.

Private Sub cboFind_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[EN] = '" & Me![cboFind] & "'"
    Me.Bookmark = rs.Bookmark
    frmFlexSubform.SetFocus

"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message 
news:Ojku697VHHA.480@TK2MSFTNGP02.phx.gbl...
> You have a field named Name?
> Access is very likely to get that confused.
> Rename the field in your tables, queries, forms, reports, macros and code.
>
> To test what's going on, try:
>    Dim rs As DAO.Recordset
>    Dim strWhere as String
>
>    strWhere = "[name]= """ & Me.cboLook & """"
>    Debug.Print strWhere
>
>    Set rs = Me.RecordsetClone
>    rs.FindFirst strWhere
>    If rs.NoMatch Then
>        MsgBox "Not Found"
>    Else
>        me.bookmark = rs.bookmark
>    End If
> etc
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Song Su" <csitnnn@hotmail.com> wrote in message
> news:OEIfe47VHHA.4668@TK2MSFTNGP04.phx.gbl...
>>I want to use combo box to locate a name. After update, the combo box 
>>shows the name but the form does not move to the record of combobox. Here 
>>is my code:
>>
>> Private Sub cboLook_AfterUpdate()
>>
>>    Dim rs As DAO.Recordset
>>
>>        'Search in the clone set.
>>        Set rs = Me.RecordsetClone
>>        rs.FindFirst "[name]= """ & Me.cboLook & """"
>>           'Display the found record in the form.
>>            Me.Bookmark = rs.Bookmark
>>            frmFlexSubform.SetFocus
>>        Set rs = Nothing
>>
>> End Sub
>>
> 


0
Song
2/24/2007 4:12:41 AM
I figured out.
rs.FindFirst "[EN] = " & Me![cboFind]


"Song Su" <csitnnn@hotmail.com> wrote in message 
news:OBAxGo8VHHA.4796@TK2MSFTNGP05.phx.gbl...
>I took your advice and change [name] to [full_name]. I also discovered that 
>I bounded to wrong column in combo box. Now it's fixed.
>
> I want to set up 2nd combo box to search [EN]. Error message says 'data 
> type mismatch'.
> My [EN] is numerical field. how do I construct rs.FindFirst line?
>
> Thanks.
>
> Private Sub cboFind_AfterUpdate()
>    ' Find the record that matches the control.
>    Dim rs As Object
>
>    Set rs = Me.Recordset.Clone
>    rs.FindFirst "[EN] = '" & Me![cboFind] & "'"
>    Me.Bookmark = rs.Bookmark
>    frmFlexSubform.SetFocus
>
> "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message 
> news:Ojku697VHHA.480@TK2MSFTNGP02.phx.gbl...
>> You have a field named Name?
>> Access is very likely to get that confused.
>> Rename the field in your tables, queries, forms, reports, macros and 
>> code.
>>
>> To test what's going on, try:
>>    Dim rs As DAO.Recordset
>>    Dim strWhere as String
>>
>>    strWhere = "[name]= """ & Me.cboLook & """"
>>    Debug.Print strWhere
>>
>>    Set rs = Me.RecordsetClone
>>    rs.FindFirst strWhere
>>    If rs.NoMatch Then
>>        MsgBox "Not Found"
>>    Else
>>        me.bookmark = rs.bookmark
>>    End If
>> etc
>> -- 
>> Allen Browne - Microsoft MVP.  Perth, Western Australia
>> Tips for Access users - http://allenbrowne.com/tips.html
>> Reply to group, rather than allenbrowne at mvps dot org.
>>
>> "Song Su" <csitnnn@hotmail.com> wrote in message
>> news:OEIfe47VHHA.4668@TK2MSFTNGP04.phx.gbl...
>>>I want to use combo box to locate a name. After update, the combo box 
>>>shows the name but the form does not move to the record of combobox. Here 
>>>is my code:
>>>
>>> Private Sub cboLook_AfterUpdate()
>>>
>>>    Dim rs As DAO.Recordset
>>>
>>>        'Search in the clone set.
>>>        Set rs = Me.RecordsetClone
>>>        rs.FindFirst "[name]= """ & Me.cboLook & """"
>>>           'Display the found record in the form.
>>>            Me.Bookmark = rs.Bookmark
>>>            frmFlexSubform.SetFocus
>>>        Set rs = Nothing
>>>
>>> End Sub
>>>
>>
>
> 


0
Song
2/24/2007 6:34:42 AM
Reply:

Similar Artilces:

Increase Size Of Auto Fliter Drop Down Box
Good evening all, I am looking for some code so that I can increase the Depth of the auto -fliter drop down box, ie to increase the number of entries visible, but without changing the font size. Having searched Google, there are many reccomendations for increasing the apparent size of the font ( by using zoom), but cannot find anything to help with increasing the size of the box itself. I have found some very useful code to increase the size (width) of the Name Box, and would appreciate some help to similarly increase the depth of the Auot filter drop down box. I would be grateful for any ...

Using online services from Europe
I'm going to be temporarily stationed in Europe for a couple of months. Are there any problems with my using M2002 to access my accounts, pay bills, etc, from there just as I do from the US? TIA You should be fine, so long as you have a 128 bit encryption version of IE. If you do have problems, please feel free to post here :-) -- Glyn Simpson, Microsoft MVP - Money Check http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny for UK tips and fixes for MS Money. To send Microsoft your wishes or suggestions, use http://register.microsoft.com/mswish/suggestion.asp or email mnyukwsh...

I need to compare 3 numbers and find the one in the middle
I have three numbers in a single row and would like to identify the middle number enter that number in another cell. Example: 1st # 2nd # 3rd # result 628 678 720 678 655 625 700 655 748 720 725 725 is there a function in excel that can do this? Thanks, Eddie Try =LARGE(A1:C1,2) VBA Noo -- VBA Noo ----------------------------------------------------------------------- VBA Noob's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3383 View this thread: http://www.excelforum.com/showthread.php?threadid=56811 fasteddie wrote.....

Find Duplicate names and delate
Dear experts, I have a small doubt could you clarify that??? That is I find duplicate name but I want to delete one name only, if I filter DUPLICATE….. both names are showing… 1. Select the range of data including the header. You need to have headers for these columns 2. From menu Data>Filter>Advanced Filter>Copy to another location 3. In 'copy to' specify the target cell and check 'Unique records only' 4. Click OK will give you the unique list -- Jacob "Find Duplicate names and delate" wrote: > Dear experts, > I have a small ...

Find a Value the first Time It Occurs
I have a row of values that shows the total cumulative number of sales of items by month. Occasionally, there may be no sales in a month for an item so the cumulative value would stay the same for more than one month. I want to select a number in the row the first time it occurs and not select it if it repeats. What are you wanting to do with the info? To return position (column number) of number 1234 within row 2: =MATCH(1234,2:2,0) A formula that signals it's the first occurence: =COUNTIF($A2:A2,A2)=1 This could be used in a helper row, or as a conditional format f...

Finding a Median
I'm trying to write a query that will return a median for various values taken from a previous query. I've seen some suggestions in my searching, but I haven't been able to get them working. They are also all from before 2003 and refer to Access 97 and 2000. Has any functionality been added to 2003 for this? Or is there a non- code-based way to do it? I've seen it suggested to write a code to open the query, sort it, find the total number of records, divide it in half, then seek out the middle record using that value. I'm still very green when it comes to code, though...

How did you add text into publisher, without using boxes?
how do you add text to publisher without using text boxes I suppose you could create your text as an image and insert the image into your publisher file. -- Don Vancouver, USA "Calvin Scott" <Calvin Scott@discussions.microsoft.com> wrote in message news:64D23D52-138D-47B4-B265-4A41BF14BF55@microsoft.com... > how do you add text to publisher without using text boxes Calvin Scott <Calvin Scott@discussions.microsoft.com> was very recently heard to utter: > how do you add text to publisher without using text boxes You don't. Text in Publisher has to e...

Does any guy use MS CRM in reality life?
I am a beginner at CRM and would like to know whether this CRM deserve to be use. I have many customers using CRM in real life :-) If you are looking to implement Microsoft CRM at your company you need to do some initial work to fully understand your business needs. Only once this is completed can you determine whether Microsoft CRM is the right product for your business. -- John O'Donnell Microsoft CRM MVP http://www.mscrmfaq.us "Hightide Software Company" <HightideSoftwareCompany@discussions.microsoft.com> wrote in message news:F95F647E-768C-4861-9053-08B67A303DBA@...

Find/Replace in RichEdit 2.0
I'm using Windows ME and I've switched from RichEdit 1.0 to 2.0 for my CRichEditDoc/View application so that I can use the ITextDocument interface and can do things such as suspend/resume the Redo buffer. Problem is, now the Find/Replace dialogs don't seem to do anything. If I revert back to RichEdit 1.0 they do! What's going on? BUMP! adriangibbons@yahoo.co.uk (Adrian Gibbons) wrote in message news:<34a2acd5.0404130713.123dbaab@posting.google.com>... > I'm using Windows ME and I've switched from RichEdit 1.0 to 2.0 for my > CRichEditDoc/View application...

Non printing of check boxes in a Report
I have come back to using Access and although I have managed it before I cannot get Check Boxes to print in a Report. They are visible on screen but when I want to print the Reports the space where the check boxes should be whether 'a tick' or 'blank' is empty. Try changing the font. It may be something your printer doesn't have the font for, while substituting another similar font for other characters. "Jenny" <Jenny@discussions.microsoft.com> wrote in message news:71D46938-AA7C-4C43-8284-B763FD955FAB@microsoft.com... >I have come back to using ...

Find (but not find)
My program takes a name from sheet3 goes to sheet1 to Find the name. If it cannot find name, how do you do an If/End to Exit Do while or find out if name has been founf? I have "On Error Resume Next" in program. Thanks again for all your help Gordon As ALWAYS, post your code for comments & suggestions. -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "Gordon" <gwelch1938@yahoo.com> wrote in message news:1184612089.486737.144020@n60g2000hse.googlegroups.com... > My program takes a name from sheet3 goes to sheet1 to Find the na...

Using in Bookshop
Greetings, I was wondering if anyone is using Retail Manager in a Bookshop and if so how they went about importing new items that were supplied in ONIX or BISAC format. We get over 600 titles every month that we would want to import and would love to think that someone has already writtena script or something to import into the database the new items.? Regards ...

Find value in a column and insert rows above
The set up looks like this: ColU ColV ColW ColX Y N N N Y N N N N Y N N N N Y N N N Y N N N Y N N N Y N N N Y Y Columns will always be U through X and will always be sorted in this order. I need to find the first Y in each column and insert 2 rows above that row. On the blank row above the first Y, I need to highlight in yellow and put title in the first cell, such as New, Old, Existing, Deleted. Any help would be greatly appreciated. Thanks for your time, Dee If desired, send your file to my address below. I will only look if: 1. You send a copy of this ...

saving a copy of deleted records
I am writing a vb6 interface for an access database. I want to be able to delete records so they no longer register on the database but at the same time it would be good if all the deleted data was stored away somewhere - rather like the recycle bin in Windows. I would welcome suggestion on the best way to do this. Is there any standard way to do it? There are a number of related tables with 'Cascade Delete Related Records' set. Thanks Nod The easiest thing to do would be simply to add a checkbox to the table so that if you don't want people to see certain records tick it. D...

Finding an event
Hello, I am developing an app that uses a single worksheet to enter data. When user double clicks a button, a new window (in same workbook) opens with a new sheet. My problem is that excel does not seem to have any events for close of window if there are multiple windows in a workbook. Can someone help Peter Peter, That triggers the Workbook_WindowActivate event, you can use that. HTH Bob "Peter Ostermann" wrote in message news:i9m5v8$7bv$02$1@news.t-online.com... Hello, I am developing an app that uses a single worksheet to enter data. When user double clicks a button...

cannot find database
I have an excel spreadsheet that is supposed to update a access db. Whenever I try to save the .xls I get an error stating cannot find db. Even when I open the db with access, I get the error and the db opens anyway?????? This only happens on 2 out of 20 pc's and I cannot figure out why???????? Thanks ...

Sum if Condition is Equal in Range Date and find column
I want to make a sum if Range is a week number and if style is Equal to CONC-92 or CONC-45 Week# 49 Week# 50 CONC-92= 27 CONC-92= 30 CONC-45= 27 CONC-45= 30 Datas are in a pivot table and... Pivot table looks like this: Date CONC-92 CONC-45 CONC-92 CONC-45 12/7 5 5 10 10 12/8 2 2 10 10 12/9 5 5 10 10 12/10 5 5 10 10 please help -- Lorenzo Díaz Cad Technician ...

Trying to collapse a table, what Function should I use?
I have a table of data (numbers) which is 70 rows by 21 columns, which I would like to summarize into a 5 x 3 table. So every 14 rows by 7 columns sums into a single cell on another worksheet. My original table would be like 1 2 3 ... 20 21 1 2 .... 69 70 and my summary table would be 01-07 08-14 15-21 01-14 A B C 15-28 D E F 29-42 G H I 43-56 J K L 57-70 M N O where A = sum of all numbers in the intersection of rows 1-14 and columns 1-7 where O = sum of all numbers...

Trapping a NO FIND after a find
I use the code below to store a row number to a variable after a find. I would like to trap a NO FIND if the find is unsuccessfull Any ideas. FSt1 provided the code below Sub macfindrow() dim rn as string dim rng as range dim therow as long rn = inputbox("enter something to find") if rn <> "" then Set rng = nothing Set rng = range("A1:IV65536").Find(what:=rn, _ After:=Range("A1"), _ Lookin:=xlformulas, _ Lookat:=xlpart, _ ...

How do I find the out of office reply?
My out of office reply is missing from tools. How can I retrieve it? Out of Office reply <Out of Office reply@discussions.microsoft.com> wrote: > My out of office reply is missing from tools. How can I retrieve it? Unless you are using an Exchange server, you will not have the Out of Office Assistant. See this: http://www.slipstick.com/rules/autoreply.htm -- Brian Tillman ...

Insert Signature using keyboard question
Hi Using 2007 When creating an e-mail, is it possible to insert a signature using keyboard strokes? -- Martin ���� Try Alt+N, G. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Martin ©¿©¬ @nohere.net" wrote: > Hi > Using 2007 > When creating an e-mail, is it possible to insert a signature using > keyboard strokes? > -- > Martin > ©¿©¬ > On Wed, 8 Oct 2008 05:39:01 -0700, Sue Mos...

Updating the row source of a combo
Hello, I have a form which contains a comboBox representative of one of my fields. The options available in this comboBox are dependant on the other feilds for the current row. Therefore I use Form_Current to update the row source for the combo. The problem is that this update seems to happen too late. As a result, I sometimes have nothing in my comboBox's text box, even when I know a value should exist there. If I click in the combo's text box the correct value will then appear. How might I solve this problem. Thanks, Aine. On 28 May 2007 07:00:45 -0700, aine_canby@yahoo.com wrote...

List box (and queries) not sorting dates or showing correct headers
G'day all, I have inherited a system with a search function screen that is acting weird. There are actually two search screens, both constructed in a similar fashion, but the first does what it is supposed to do and the second is misbehaving. The form has a bunch of unbound controls allowing the user to enter search criteria. The only mandatory criteria is the sort order, which is set from a combo box. The data source for the combo box is a table, sys_GAPSSortBy, which contains a list of query names and a user- friendly label for use by the combo box. When the user clicks the "Searc...

Finding numbers in rows and highlighting them
Hi everybody :) I need help. This is a lotto system. I have a spreadsheet with 508 rows and 45 columns. In each row there are 45 numbers mixed (1 to 45). I need a script or some other way to find where particular (drawn) numbers are in each of the 508 rows. If my explanation is not clear please ask for farther clarification. Thank you in advance for your help. Joh -- Johncobb4 ----------------------------------------------------------------------- Johncobb45's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1658 View this thread: http://www.excelforum.com/showt...

How do I use .Create on a control class?
For example, I want to progamatically add a CEdit to the main dialog in a dilaog based app. So, I declare a CEdit object called skill, then I call skill.Create(<style flags>, <rect>, <CWnd*>, etc... The question is this, where do I get the CWnd* ? I can declare one, but what do I initialize it to? I have tried using "this" as my CWnd* but if I do that, the control does not show up in the dialog. I did specify WS_CHILD and WS_VISIBLE in my style flags. What am I doing wrong? CWnd* is the base class of CDialog*, just pass it 'this' (self reference ...