validating combobox

jhedonghae

Member
Joined
Mar 29, 2012
Messages
17
Programming Experience
Beginner
please kindly help me!!!
what i wanted is when i select items in the combobox and it is already in the database it will prompt that it is already in the database..tnx

here is my code:

01Private Sub ComboBox3_Validating(ByVal sender As Object, ByVal e AsSystem.ComponentModel.CancelEventArgs) Handles ComboBox3.Validating

02If ComboBox3.Text = "'" Then

03con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")

04Dim ewaaa As String = "Select * from Schedulings where YearLevels = '" & ComboBox3.Text & "' And Sections = '" & ComboBox1.Text & "' "

05com = New OleDbCommand(ewaaa, con)

06con.Open()

07rid = com.ExecuteReader

08rid.Read()

09If (rid.HasRows) Then

10ComboBox3.Text = rid(2)

11MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error")

12ComboBox3.SelectedIndex = -1

13End If

14End If

15End Sub




i think the problem is in this part "If ComboBox3.Text = "'" Then" i just don't know how to manipulate combobox when the event is validating...please help me
 
In that case, why does the drop-down list contain values that the user can't select in the first place. Prevention is always better than cure. I would find it very annoying if an application let me choose a value and told me it was wrong if it could have simply not showed me the value in the first place. Is that possible in your case?
 
So all you need to put in the list is those that don't produce a conflict then, but you're putting all the ones that will produce a conflict as well. How would you feel if you had a list of items to select from and each time you selected one you were told that it wasn't available? Wouldn't you think that the person who created the list in the first place should not have included those items if they couldn't be chosen? The users of your app will feel the same way.
 
So all you need to put in the list is those that don't produce a conflict then, but you're putting all the ones that will produce a conflict as well. How would you feel if you had a list of items to select from and each time you selected one you were told that it wasn't available? Wouldn't you think that the person who created the list in the first place should not have included those items if they couldn't be chosen? The users of your app will feel the same way.


i don't think that well work
 
Back
Top