how to focus on a specific record when clicking a row on a combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billef32
    New Member
    • Jul 2013
    • 4

    how to focus on a specific record when clicking a row on a combobox

    I've made a database for my contacts. On the top of my main form (names) I put a combobox where the row source is :
    Code:
    SELECT [names].[ID]
       , [names].[firstname]
       , [names].[lastname] 
    FROM [names] 
    ORDER BY [lastname];
    that will show me a list of ID name and last name of each record (each row of that list is a record). I want everytime that I click on a row of that list to focus on that record.
    Last edited by billef32; Jul 4 '13, 07:28 PM.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    You will need to do this via VBA in the afterupdate/onchange events.

    You may find these methods of some help:
    Last edited by zmbd; Jul 4 '13, 07:41 PM. Reason: [z{made the different links more obvious}]

    Comment

    • billef32
      New Member
      • Jul 2013
      • 4

      #3
      thanks but I don't know how to do this... can you provide me an example or something? or a source with way less info than the link you provided me? there are almost 200 things there and I don't know what will work for me. :/

      someone messaged me that I have to do this from the event on the properties of my combobox.. will this do? if yes what I have to type exactly?

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        There are 4 links in my post.
        The first is just the general link to all of the available articles.
        Then the links to articles #42, #55, and #168.

        As for PM, the suggestion is as I have given in the first part of my post. The links in the articles will explain some of this to you.

        You might remind the person that pm'd you that responses should be made within the threads where we can all benefit from the efforts.
        Last edited by zmbd; Jul 4 '13, 07:44 PM.

        Comment

        • billef32
          New Member
          • Jul 2013
          • 4

          #5
          I checked the links and they are very confusing. not sure if this is what I am looking for. Also it's like reading a whole encyclopedia for something that the answer is not that big ( I think).

          I attached an example of what I am looking for.. it's a ready-template database (along with an image). I kept only a few elements and deleted the rest of forms tables etc. so don't mind the error messages. The form still works. Go to "employee details" form (skip the error messages) and then click on the "go to" combobox. You will see a dropdown list with 1 (more) record. If I click on it then it will focus on that record. this is what I want to do .. the exact same button! I know that something has to be made with VB but I am not sure that the code is that long.

          [imgnothumb]http://bytes.com/attachments/attachment/7066d1372967750/example.jpg[/imgnothumb]
          Attached Files
          Last edited by zmbd; Jul 4 '13, 09:39 PM. Reason: [z{made the inline image visable}]

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            Please understand that most of us are either unable to open/view attachments as we're at work, or will not open an unsolicited attachment just as a matter of Best Safe Computing Practices (esp. #6 and #7). This should in no way be taken personally. It is much better to have a well worded/phrased description of the goal, the current issue, exact errors, and so forth as these will turn up in the search engines for others to find should they be in the same or simular situation as you find yourself in today.
            (more to follow)

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              We (mods/experts/admins) must work with the concept that the posters have a moderate working knowledge of MS Access and its GUI design interface (can make a query, can make a form, etc), SQL (at least as it relates to Access), and a working knowledge of VBA and how to get into the VBA-Editor.

              What you are asking for is both simple and complex; hence, why I posted the other links.

              Modification of a template can be very frustrating, especially if the designer used a mix of macros and vba.
              You didn't mention which version of Access you are using so I will proceed as though you are using v2010:

              In your case, I would suggest that you open in design view the form that has the operations as you'd like to have on the second form.
              Right-Click on the control (the combobox) that has the behavior that you desire, in the popup, select "properties ."
              Now click on the event tab at the top of the properties box.
              You will now see a list of events along the left and if there is associated macro/code you will see something like "[Event Procedure]" (vba) or [Embedded Macro] (macro).
              You will need to look at the afterupdate and onchange events.
              Review this code and see how they are doing the operation.
              Once you understand how things are working, you can then copy and paste the code into the second form and modify it for the forms recordset.
              Last edited by zmbd; Jul 4 '13, 08:41 PM.

              Comment

              • billef32
                New Member
                • Jul 2013
                • 4

                #8
                (after reading you last post) I use MS Access 2007 and windows XP (but I don't think that windows have to do with this - just saying)

                Comment

                • zmbd
                  Recognized Expert Moderator Expert
                  • Mar 2012
                  • 5501

                  #9
                  The OS shouldn't be an issue, knowing that you are attempting to modify a template and that you are using MS Access 2007 will be helpful.
                  - The directions I posted for 2010 will work for 2007

                  Once you get into the propeties on the control that does what you want please let us know which ("[Event Procedure]" (vba) or [Embedded Macro] (macro)) type of code is indicated. It will make a HUGE difference in helping you to post it and modify it for your use.

                  ONE MORE THING---
                  BACK UP YOUR FILE BEFORE modifying it too much. That way if we goof you haven't lost much if anything.
                  Last edited by zmbd; Jul 4 '13, 09:37 PM. Reason: [z{added the backup rant}]

                  Comment

                  Working...