+ Reply to Thread
Results 1 to 3 of 3

Combo Box to find records on Form - coding problem

  1. #1
    Registered User
    Join Date
    12-02-2009
    Location
    New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    10

    Combo Box to find records on Form - coding problem

    I have the following code in the AfterUpdate event on a combo box, which is in the header of a Form (which is based on an underlying table). The combo is used for finding records in the form body, not for populating any fields.

    Please Login or Register  to view this content.
    The combo is calling from a query which filters the table/form records according to a criteria placed on a certain textfield, and has 3 other fields besides in the query: EmpID (AutoNumber, Primary key) and 2 textfields named forename and surname". These two text fields are used in the Combo columns.

    So the above works, sort of: The ComboBox populates with the filtered records & then I select for eg. "John DOE" (forename/surname) from the Drop-Down - the AfterUpdate event kicks in, and the form shifts to the matching record - but obviously, it only works for me if there is only ONE instance of the selected forename in the records. And because my database contains multiple records with the same forename (and surname), the above code only finds the first instance of the "forename", not necessarily the one I want.
    EG: If I want to go to (and 'select' the "John SMITH" record in the Combo, it will only take me to "John DOE" on the form (found first)

    So I tried to redo the combo, by including the unique "EmpD" field in it, making it Column 1 in the Combo - and replacing "Forename in the code, with "EmpID ie: I want the combo selection to find matching "EmpID" in the form.

    This doesn't work - I'm guessing because "EmpID" is not a text-field - whereas the code is written for a text field??

    If I keep the redone Combo - can the AfterUpdate code above be changed to make it find the selected "EmpID" autonumber on the form?

    If I revert to the original combo (with just forname and surname) can I change the above code so that it find the matching combination of Forename & Surname in one record on the form?

    Thanks :-)

    annieb

    edited: oops, sorry royuk - have changed to code tags!
    Last edited by annieb; 12-01-2010 at 09:29 AM. Reason: Changed to Code tags

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combo Box to find records on Form - coding problem

    Please use Code Tags, not Quote Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Combo Box to find records on Form - coding problem

    Annieb;
    Are you able to post your db with some sample data? This would give us a better idea on how to evaluate what you are doing and offer some sound advise to resolve your issue. It is sometimes difficult to envision exactly what is happening without viewing the actual situation.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1