I need to choose a value from a combo box and check if that exists in a table and if it does..i need to make a button glow green..

I am not sure how I have to check if the chosen value exists in that table..

can you please help me with that ?
--------------------------------------------------------------------------------
My code does the rest of the things that I want it to.. This is my code for the database but I am not sure how to see if the combobox chosen value exists in my master database!! Please assist!!

imports System.Data.oledb

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim objcmd As New Data.OleDb.OleDbCommand

Dim objrdr As Data.OleDb.OleDbDataReader

Dim TableName1 As String = ""

Dim query1 As String = ""

Dim cbo1 As ComboBox = Nothing

Using con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")

con.Open()

For x As Int32 = 1 To 4

Select Case x

Case 1

query1 = "SELECT DISTINCT MFG FROM table1 WHERE MFG IS NOT NULL ORDER BY MFG"

TableName1 = "MFG"

cbo1 = ComboBox1

Case 2

query1 = "SELECT DISTINCT MAKE FROM table1 WHERE MAKE IS NOT NULL ORDER BY MAKE"

TableName1 = "Make"

cbo1 = ComboBox2

Case 3

query1 = "select distinct GRAPHICSCARD from table1 where GRAPHICSCARD is not null"

TableName1 = "GRAPHICSCARD"

cbo1 = ComboBox3




Case 4

query1 = "select distinct GRAPHICSVERSION from table1 where GRAPHICSVERSION is not null"

TableName1 = "GRAPHICSVERSION"

cbo1 = ComboBox4




End Select

objcmd.Connection = con

objcmd.CommandText = query1

objrdr = objcmd.ExecuteReader

cbo1.Items.Clear()

If objrdr.HasRows Then

Do While objrdr.Read

cbo1.Items.Add(objrdr.GetValue(0))

Loop

End If

objrdr.Close()

Next

End Using

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

End

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Map Database.mdb")

Dim cmd As New OleDbCommand

con.Open()

cmd = New OleDbCommand("select * from table1 where Mfg like '%" & ComboBox1.SelectedItem & "%' and Make like '%" & ComboBox2.SelectedItem & "%' and GraphicsCard like '%" & ComboBox3.SelectedItem & "%' and GraphicsVersion like '%" & ComboBox4.SelectedItem & "%'", con)

Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)

Try

Dim ds As DataSet = New DataSet()

ds.Tables.Add("table1")

da.Fill(ds, "table1")

DataGridView1.DataSource = ds.Tables("table1").DefaultView

Finally

con.Close()

cmd = Nothing

da.Dispose()

con.Dispose()

End Try






End Sub

End Class

--------------------------------------------------------------------------------
i want it to be somewhat like this.. but using 'Mfg' which is a field in my Master DB like this is not appropriate,..can u pls suggest something ?
If (Mfg = " & combobox1.selecteditem & ") Then

Button1.BackColor = System.Drawing.Color.IndianRed

End If

Is this a VB or VB.NET coding?

I was just told you made another post in VB.NET section of the forum. It is not nice to flood forum with same questions in various sections of the forum. Please do not do so in the future as it is against rules. Please have look on forum policies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.