Using list box to populate fields on a form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ne0nhal0
    New Member
    • Oct 2008
    • 3

    Using list box to populate fields on a form?

    I don't consider myself as anything more than an Access newbie, so please bear with me if I don't understand some syntax et cetera.

    Right. Time to jump into the problem.

    I have a form, lev3_site, which I will use to show details of places where our hardware is set up (I work for a rail company, so this hardware is set up all over the UK, and more). On this form there is a list box (currently with no data source), which will take the field 'Sitename' from a table (tbl_siteinfo) and display the results - I still haven't done this yet, bearing in mind I might not actually know how to do this!

    What I want to do, is when a site name is clicked in said list box, a number of fields on the form (listed below) are populated with the corresponding details (also housed in tbl_siteinfo).

    The fields I wish to be populated on the form are site name, maintainer and contact number for now (these are Sitename, Maintainer and ContactNo respectively in tbl_siteinfo).

    I just noted I have a tendancy for brackets. That's quite annoying. (Yes, it is.)

    Anyway. When it comes to coding, I'm absolutely rubbish. I have no clue as yet how to do any of the above, which is why I'm here - I won't pretend I'll understand any answer completely, but it'd certainly help me getting to grips with VBA and Access.

    Also, there is another problem I have, but I suppose I'll leave that until I've managed to overcome this one.

    If copies of the database, tables, forms etc are needed, drop me a line.

    Thanks,

    Matt
  • ne0nhal0
    New Member
    • Oct 2008
    • 3

    #2
    Oh yes, and I'm using Access 2002.

    I can't believe I forgot that...

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Matt,

      I can't help feeling that a bit of tutorial work or training is appropriate before this stage of your problem. We are happy to help you whenever we can, but until you understand the language, there will just be too much frustration and confusion.

      Access is not a toy to be picked up so easily (quite the reverse of what Microsoft would have everyone believe). Don't get me wrong, it's not "hard" either, but there are basics, without the understanding of which, you will be fundamentally lost, and we will get frustrated trying to convey ideas.

      Access tutorials are very easy to find on the web, and Access even comes with its own inbuilt tutorials.

      As far as your question is concerned, you may want to take a look at Example Filtering on a Form to start with, but I suspect it will require some very basic experience to be understood easily.

      Comment

      • ne0nhal0
        New Member
        • Oct 2008
        • 3

        #4
        NeoPa,

        Thanks for your quick reply. I understand that I -do- need training, sadly my work see it as a 'learning experience' to do all of this unguided and untrained. I've been told to create this database, and if I can't do it then I will quite probably be let off. This isn't fair, I know, however it seems everyone who has had my job position has been given this task to 'prove themselves worthy' to work here. Heh, this is the only time in this job I'd need to use Access..

        Thanks for the link. I've seen quite a few pieces of demonstration code, tutorials etc over the internet, I just find it quite hard to relate it to my problem.

        Thanks anyway though.

        -Helpless on Helpdesk

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Well, as I mentioned before, I can't promise this will make much more sense to you, but I'll try.

          When you make a selection in your ListBox control, this will trigger an event that you can handle. The event is called the AfterUpdate event and there is one possible for each (updatable) control.

          The code in here would have to determine the new value an then update the other controls based on that value.

          It's better to assign the values to the .DefaultValues of the controls rather than to their .Values. That way, the record is still not considered to be changed until the operator changes any of the bound controls.

          I'm conscious you may not be familiar with all the terms even here - I just hope somehow it makes sense.

          Comment

          Working...