Trouble with combobox update from button onclick event.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munkee
    Contributor
    • Feb 2010
    • 374

    Trouble with combobox update from button onclick event.

    A very simple question which I cant answer myself at the meoment due to epic tiredness.

    I have a combobox in my access 2003 database which is populated with the real names of users taken from a securtiy table based on their securityID number.

    The rowsource of the combobox therefore is:

    Code:
    SELECT SecurityID, [FName] & " " & [SName] AS Name FROM tblSecurity;
    This allows an admin to select the user who will be the owner of a current record on a form. What I wish to add is a button placed beside this combobox, which upon being clicked will set the combobox value to that of the person who clicked it. Therefore assigning ownership to themselves.

    Code:
    Private Sub btnMeOwner_Click()
    On Error GoTo BrokenDown
    
        Me.Owner = Forms!frmhidden.txtSecurityID
    
    Quitter:
    Exit Sub
    
    BrokenDown:
    MsgBox Err.Description
    Resume Quitter
    End Sub
    The above code takes the securityID (which is the bound column of the combobox) from a hidden form I use to authenticate throughout the database. The problem I am having is that when I click the button the value is not updated until I set focus to the box (manually by clicking in).

    I have tried to refresh the combobox using:

    Code:
    Private Sub btnMeOwner_Click()
    On Error GoTo BrokenDown
    
        Me.Owner = Forms!frmhidden.txtSecurityID
        Owner.Requery
    
    Quitter:
    Exit Sub
    
    BrokenDown:
        MsgBox Err.Description
    Resume Quitter
    End Sub
    And also refresh and setfocus etc but nothing seems to work I just get the error:

    "Method or data member not found" on the Owner.Requery line.

    Thanks for any input,

    Chris
  • munkee
    Contributor
    • Feb 2010
    • 374

    #2
    Ignore this,

    I have been very very stupid and realised I was referencing the table field name Owner and not the combobox name NCOwner.. this will teach me not to use misleading naming conventions!

    Comment

    Working...