How to update a field based on combobox selection?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Emily Walshaw
    New Member
    • Dec 2010
    • 1

    How to update a field based on combobox selection?

    I'm sorry, I know this has been asked a million times, but am completely new to access and need idiot proof help. I have a database and I am struggling to get a field to update based on a combobox selection. I have

    tbl_Hazards - fields are numerous, inc risk rating and priority.
    tbl_Risks - fields are key, risk rating, priority
    frm_Hazards.

    On the form I have a Risk Rating combobox that sources data from tbl_Risks, then stores data in tbl_Hazards.

    I want, based on the selection from the combobox the priority field (text box) to update with the appropriate value. e.g. Risk Rating = High, Priority = High.

    I can get the priority text box to update based on the combobox selection if I set the text box control source to =Risk Rating.column2 but it will not update the priority field in tbl_hazards (as it is no longer bound to tbl_Hazards).

    I have tried the AfterUpdate in the risk rating combobox Private Sub Risk_Rating_Aft erUpdate()
    Me.Priority = Me!Risk_Rating. Column(1)
    Me.Refresh
    End Sub

    and keep the text box control source linked to the priority field, but it does not seem to do anything...i have no idea where I am going wrong, can someone please help...
  • beacon
    Contributor
    • Aug 2007
    • 579

    #2
    Hi Emily,

    Check out this website. I refer to this from time to time when I need to implement cascading lists/textboxes/comboboxes.

    I think you're on the right track with what you've tried so far, but since you're trying to grab a value in a column that isn't bound, I would recommend using the SQL implementation on the site I provided so you can pin point the exact column you want to appear in your combobox.

    Hope this helps,
    beacon

    Comment

    Working...