|
-
Aug 13th, 2009, 03:34 PM
#1
Thread Starter
Addicted Member
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.
-
Aug 13th, 2009, 03:44 PM
#2
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 -
-
Aug 14th, 2009, 09:08 AM
#3
Thread Starter
Addicted Member
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.
-
Aug 14th, 2009, 09:11 AM
#4
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 -
-
Aug 14th, 2009, 09:53 AM
#5
Thread Starter
Addicted Member
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
-
Aug 14th, 2009, 10:16 AM
#6
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 -
-
Aug 14th, 2009, 10:39 AM
#7
Fanatic Member
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
-
Aug 14th, 2009, 10:55 AM
#8
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 -
-
Aug 14th, 2009, 11:41 AM
#9
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|