Results 1 to 9 of 9

Thread: fill combobox depend from logon username

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    176

    fill combobox depend from logon username

    Hi All.
    I have Logon and Detail forms. In Detail form combobox populated by Employee table. I would like, when user logon and open Detail form the combobox will automatically display name of employee who logon.
    Thanks.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: fill combobox depend from logon username

    Well, when the user type their id on the logon form, you know who the user is... So just pass that id to the detail form and set the selectedvalue of the combobox to that id (assuming you have the combobox.ValueMember = "ID").
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    176

    Re: fill combobox depend from logon username

    Hi stanav, thaks for replay.
    I try to use your suggestion, but I got error message:
    Cannot bind to the new value member. Parameter name: value
    How to fix that problem?
    Thanks.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: fill combobox depend from logon username

    Can you show the code where you fill the combobox in the detail form?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    176

    Re: fill combobox depend from logon username

    Tanks for help.
    Code:
    Private Sub HRDetailForm_SetForm(ByVal Sender As Object, ByVal e As System.EventArgs) Handles Me.SetForm
            Me.EmployeesTableAdapter.DropDownFillBy(Me.HRDataSet.Employees, 0)
    End Sub
    
    Private Sub HRDetail_SetData(ByVal Sender As Object, ByVal e As System.EventArgs) Handles Me.SetData
            Me.EmpComboBox.SelectedValue = IIf(IsDBNull(Me.DataRow("EmpID")), 0, Me.DataRow("EmpID"))
             Me.EmpComboBox.ValueMember = "UserNameID"
    End Sub

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: fill combobox depend from logon username

    What type of object is "Me" in your code? SetForm and SetData events? Never seen them before.... I'm afraid that you need to post the full code of your detail form so that I can follow and understand it.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #7
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: fill combobox depend from logon username

    the "me" keyword refers to the current form/class you are in. So if you have a text box on form1 using me.textbox.text is the same thing as saying form1.textbox.text (while in form1).

    The problem is coming in from setting the value member property. take a look at this link to see if it helps you...

    http://www.vbforums.com/archive/index.php/t-465236.html

  8. #8
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: fill combobox depend from logon username

    I know that the keyword "Me" refers to the current instant of the object that the code is executing on. What I'm asking is what Type that object is. It's obviously not a regular Form since the Form class doesn't have the SetForm and SetData events.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  9. #9
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: fill combobox depend from logon username

    excuse me, I misread your question. Only had a chance to grab one cup of coffee this morning

Posting Permissions

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



Click Here to Expand Forum to Full Width