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.
Printable View
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.
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").
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.
Can you show the code where you fill the combobox in the detail form?
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
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.
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
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.
excuse me, I misread your question. Only had a chance to grab one cup of coffee this morning ;)