systems_ax
asked on
selecting 1 value from 3 different combo boxes at one time and individually with visual basic 05
I have 3 combo boxes and I need to be able to select from each combo box individually and at the same time also.
I want them to select 1 value from combo box 1 and then all the reports will show only based on this search criteria, which my code does show.
I want them also to select 1 value from each combo box at the same time and the reports that match these three criteria will show within the datagridview. Then they will go up to combo box 1 and base their search on only 1 value selected from combobox 2.
Is there such flexibility with combobow, I have read something about "UNION" between the 3combo boxes but did not find any good tutorials.
Can someone please help out.
I want them to select 1 value from combo box 1 and then all the reports will show only based on this search criteria, which my code does show.
I want them also to select 1 value from each combo box at the same time and the reports that match these three criteria will show within the datagridview. Then they will go up to combo box 1 and base their search on only 1 value selected from combobox 2.
Is there such flexibility with combobow, I have read something about "UNION" between the 3combo boxes but did not find any good tutorials.
Can someone please help out.
ASKER
weellio,
I apologize for not being clear.
I have 3 combo box:
combo box 1: contains-apple, pear, grapes
combo box 2: contains-whip cream, sugar, salt
combo box 3: contains-low calorie, medium calorie, high calorie food
Right now I have the coding that pulls the reports from Access database based only on 1 selection of combo box, which is "changed index" event.
How do I do it when I want to NOT ONLY to select 1 item from 1 whatever combo box on at a time BUT ALSO be able to select 1 value FROM EACH combo bow at the SAME TIME AND PULL THE REPORTS THAT CONTAIN FOR EXAMPLE: APPLE, SUGAR,and LOW CALORIE.
i HAVE READ SOMETHING ABOUT "union" but the posts were not clear to me.
I know that it is posisble I just do not know where to start and how to start on this extra feature.
Please advise.
Thank you very much.
I apologize for not being clear.
I have 3 combo box:
combo box 1: contains-apple, pear, grapes
combo box 2: contains-whip cream, sugar, salt
combo box 3: contains-low calorie, medium calorie, high calorie food
Right now I have the coding that pulls the reports from Access database based only on 1 selection of combo box, which is "changed index" event.
How do I do it when I want to NOT ONLY to select 1 item from 1 whatever combo box on at a time BUT ALSO be able to select 1 value FROM EACH combo bow at the SAME TIME AND PULL THE REPORTS THAT CONTAIN FOR EXAMPLE: APPLE, SUGAR,and LOW CALORIE.
i HAVE READ SOMETHING ABOUT "union" but the posts were not clear to me.
I know that it is posisble I just do not know where to start and how to start on this extra feature.
Please advise.
Thank you very much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
weellio,
Yes, all 3 combo boxes have data stored in 3 different tables. And all I need to be able to do is find all the reports that my code corrently does currently, but I do not know anything about how how to write a function and do not understand how the I can select 1 value from 1 combo box and it will populate the datagridview and then when I select a second combo box values it combines with the value of the first one.
Can you please give me a good link to go to for help. This is my code for all the 3 combo boxes where the data from access database is pulled individually. I am only including the code for 1 of the combo boxes because the code is the same for all three:
Private Sub Populate_Condition(ByVal MenuConditionName As String)
DataGridView1.Columns.Clea r()
OpenDB()
MenuConditionName = "'%" & MenuConditionName & "%'"
If ComboBox5.Text = "" Then
MessageBox.Show("Please Enter the Recipe Name!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information )
Else
Dim Sql As String = "SELECT MenuReport FROM MenuCondition Where MenuConditionName LIKE " & MenuConditionName
Dim cmd As New OleDbCommand(Sql, Conn)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
da.SelectCommand = cmd
Try
da.Fill(ds, "Data")
dt = ds.Tables("Data")
DataGridView1.DataSource = dt
DataGridView1.Columns(0).H eaderText = "Menu Reports"
For Each dgrow As DataGridViewRow In DataGridView1.Rows
If Not IsDBNull(dgrow.Cells("Menu Report").V alue) AndAlso dgrow.Cells("MenuReport"). Value IsNot Nothing Then
dgrow.Cells("MenuReport"). Value = dgrow.Cells("MenuReport"). Value.ToSt ring.Repla ce("d:\", "").Replace("D:\", "").Replace(".pdf", "")
End If
Next
Catch ex As Exception
MsgBox("Error while executing: (" & cmd.CommandText & ")" & vbCrLf & "Msg: " & ex.Message.ToString, MsgBoxStyle.Exclamation, "Error")
Finally
da = Nothing
ds = Nothing
dt = Nothing
cmd.Dispose()
CloseDB()
End Try
End If
end sub
Yes, all 3 combo boxes have data stored in 3 different tables. And all I need to be able to do is find all the reports that my code corrently does currently, but I do not know anything about how how to write a function and do not understand how the I can select 1 value from 1 combo box and it will populate the datagridview and then when I select a second combo box values it combines with the value of the first one.
Can you please give me a good link to go to for help. This is my code for all the 3 combo boxes where the data from access database is pulled individually. I am only including the code for 1 of the combo boxes because the code is the same for all three:
Private Sub Populate_Condition(ByVal MenuConditionName As String)
DataGridView1.Columns.Clea
OpenDB()
MenuConditionName = "'%" & MenuConditionName & "%'"
If ComboBox5.Text = "" Then
MessageBox.Show("Please Enter the Recipe Name!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information
Else
Dim Sql As String = "SELECT MenuReport FROM MenuCondition Where MenuConditionName LIKE " & MenuConditionName
Dim cmd As New OleDbCommand(Sql, Conn)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
da.SelectCommand = cmd
Try
da.Fill(ds, "Data")
dt = ds.Tables("Data")
DataGridView1.DataSource = dt
DataGridView1.Columns(0).H
For Each dgrow As DataGridViewRow In DataGridView1.Rows
If Not IsDBNull(dgrow.Cells("Menu
dgrow.Cells("MenuReport").
End If
Next
Catch ex As Exception
MsgBox("Error while executing: (" & cmd.CommandText & ")" & vbCrLf & "Msg: " & ex.Message.ToString, MsgBoxStyle.Exclamation, "Error")
Finally
da = Nothing
ds = Nothing
dt = Nothing
cmd.Dispose()
CloseDB()
End Try
End If
end sub
ASKER
and this is the indexchanged event:
Private Sub ComboBox5_SelectedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexCha nged
Populate_Condition(ComboBo x5.Text)
End Sub
Private Sub ComboBox5_SelectedIndexCha
Populate_Condition(ComboBo
End Sub
sorry for the delay,. i'll look more at this tomorrow,. here are some potentially useful links
http://support.microsoft.com/kb/q208529/
http://www.blueclaw-db.com/download/union_query_advanced.htm
http://www.fontstuff.com/access/acctut13a.htm
http://www.techonthenet.com/access/comboboxes/index.php
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarofftalk/html/office03022000.asp
SELECT a.Aaaa, b.Bbbb, c.Cccc
FROM (tblTable1 As a INNER JOIN tblTable2 As b On a.Code = b.Code) INNER JOIN tblTable3 As c On a.Code = c.Code
WHERE a.Code = Forms!frmYourForm!txtYourT extBox
http://support.microsoft.com/kb/q208529/
http://www.blueclaw-db.com/download/union_query_advanced.htm
http://www.fontstuff.com/access/acctut13a.htm
http://www.techonthenet.com/access/comboboxes/index.php
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarofftalk/html/office03022000.asp
SELECT a.Aaaa, b.Bbbb, c.Cccc
FROM (tblTable1 As a INNER JOIN tblTable2 As b On a.Code = b.Code) INNER JOIN tblTable3 As c On a.Code = c.Code
WHERE a.Code = Forms!frmYourForm!txtYourT
ASKER
weellio,
sorry but I do not need Access help I need visual basic 2005 help.
thanks
sorry but I do not need Access help I need visual basic 2005 help.
thanks
maybe adding some data to the existing functions that pull a disctionary going across the three?
where it pulls the data in each of the boxes add something like
' Declare the dictionaries outside of the function.
Dim Dict1 As Dictionary
' Create a variant to hold the object.
Dim vContainer1
' Create the dictionary instances.
Set Dict1 = New Dictionary
Function dictionary1(box, results)
'box is the particular combox#
'results is the output results
With Dict1
' Add items to the dictionary.
.Add box, results
End With
end function
to read the value
For Each vContainer1 In Dict1
'Do something
next
where it pulls the data in each of the boxes add something like
' Declare the dictionaries outside of the function.
Dim Dict1 As Dictionary
' Create a variant to hold the object.
Dim vContainer1
' Create the dictionary instances.
Set Dict1 = New Dictionary
Function dictionary1(box, results)
'box is the particular combox#
'results is the output results
With Dict1
' Add items to the dictionary.
.Add box, results
End With
end function
to read the value
For Each vContainer1 In Dict1
'Do something
next
ASKER
weellio,
thanks
thanks
give me example data that would be in the combo boxes and the results of selecting a few different options.