This is driving me nuts and is probably simple. I have an employees form. When first loaded the combobox is loaded with a list of employees, names concatenated from the firstname and lastname columns of the table during the select and the uid from the database is set for the primary key of the datatable. The combo also has a blank line added so the admin will see that first and has to select a name from the combo. What I want is when a name is selected in the combo it then populates the other textboxes on that form with the info for that particular employee name. From there they will be able to edit items then update the db. So here are parts of my code:
Populates the combobox:
User selects a name in combobox and should display data in textboxes:
I get the following error on compile:
error BC30574: Option Strict On disallows late binding.
upempFindValue(0) = cboSelectEmp.SelectedItem(0)
I assume that my error is because I Dim upempFindValue as just an object and not something specific. If that is the problem, I have no clue how to fix it.
Any Help would be appreciated.
Thanks
tk
Populates the combobox:
Code:
Private Sub PopulateCombo()
'called from formload
'sets primary key of datatable
Dim dc(1) As DataColumn
dc(0) = dtUpEmp.Columns("uid")
dtUpEmp.PrimaryKey = dc
'binds data to combobox and fills box
cboSelectEmp.DataSource = dtUpEmp
cboSelectEmp.DisplayMember = "name"
cboSelectEmp.ValueMember = "name"
'adds empty row to combox and sets box to that row
Dim dr As DataRow
dr = dsUpEmp.Tables(0).NewRow
dr(1) = ""
dsUpEmp.Tables(0).Rows.Add(dr)
cboSelectEmp.SelectedIndex = cboSelectEmp.FindStringExact("")
End Sub
User selects a name in combobox and should display data in textboxes:
Code:
Private Sub CboSelectEmpSelectedIndexChanged(sender As System.Object, e As System.EventArgs)
Dim drCurrent As DataRow
'load the uid and find values
Dim upempFindValue(0) As object
upempFindValue(0) = cboSelectEmp.SelectedItem(0)
drCurrent = dtUpEmp.Rows.Find(upempFindValue)
'populate the fields
txtUser.Text = drCurrent("username").ToString
txtFirstName.Text = drCurrent("firstname").ToString
txtMi.Text = drCurrent("mi").ToString
txtLastName.Text = drCurrent("lastname").ToString
txtMaskDob.Text = drCurrent("dob").ToString
txtMaskSsn.Text = drCurrent("ssn").ToString
txtStreet.Text = drCurrent("street").ToString
txtCity.Text = drCurrent("city").ToString
txtState.Text = drCurrent("state").ToString
txtMaskPhone.Text = drCurrent("phone").ToString
txtMaskZip.Text = drCurrent("zip").ToString
'selects correct radio button
Dim empstat As String
empstat = drCurrent("emptype").ToString
If empstat = "a" Then
rdoAdmin.PerformClick()
Else If empstat = "i" Then
rdoinactive.PerformClick()
Else
rdoEmp.PerformClick()
End If
End Sub
I get the following error on compile:
error BC30574: Option Strict On disallows late binding.
upempFindValue(0) = cboSelectEmp.SelectedItem(0)
I assume that my error is because I Dim upempFindValue as just an object and not something specific. If that is the problem, I have no clue how to fix it.
Any Help would be appreciated.
Thanks
tk