Combo Box.....HELP

PlayKid

Active member
Joined
Jun 25, 2005
Messages
38
Hi all,

I am try to make something that can update my database from my combobox, since I have 10 comboboxes on my form, and each perform the same function and had the same data source.
The scenario is that:
1. I have 2 tables that needed to update
2. I need to check whether the string that I typed on my combo box is existed on my database, if not, then add to the database.

The problems come in when I am trying to check my combo box, I tried many method, and still not working.

Can someone lead me with this?

Thanks very much

PlayKid

[VB]

Private Sub SupplierActivitesInformation()
Dim drSupplierActivities As DataRow
Dim c As Control
Dim count, countdata As Integer
dtSupplierActivities = DsSupplierActivities1.Tables("SuppliersActivities")
For count = 1 To 10
For Each c In ProvideActivitiesGroup.Controls
If (c.Name = "ComboBox" & CStr(count)) And (c.Text <> "") Then
drSupplierActivities = dtSupplierActivities.NewRow
drSupplierActivities("SupplierNo") = SupplierNo + 1

------------------------PROBLEM HERE-----------------------------------

dtSupplierActivities.Rows.Add(drSupplierActivities)
Call Savechanges(DsSupplierActivities1, daSupplierActivities)
End If
Next
Next count

End Sub
[/VB]
 
You might want to use custom attributes and mark your comboboxes with an attribute so it can be retrieved at runtime.
 
question. . . You want the user to be able to add activities to your database???

so lets say you had in the activity table:

--------------
Walking
Running
--------------

The you want the the combo box to look something like this when dropped down:

[____________]V
|_____Walking_|
|_____Running_|


Now, lets say your user "fat-fingers" the combo box and enters:

[_____Valking]V
|_____Walking_|
|_____Running_|

and submits,

Do you really want the database to reflect -

--------------
Walking
Running
Valking
--------------

??????
 
Joe:

Thats part of my idea, but since I have 10 combo boxes that do the same tricks, if I entered something on my box, then all other boxes do the same thing, which overwrites my text that I have entered on my combo box.
I have changed my code, here is my updated code, but still gives me unwanted results.
The results came back to me is, the item was added to the combo boxes successfully, but in my database, it repeated the item 10 times. its really killing me, been trying figure out the codes for a week already....

[VB]
Private Sub ActivitiesInformation(ByVal pActivityName As String)
Dim drActivities As DataRow
dtActivities = dsActivities1.Tables("Activities")
drActivities = dtActivities.NewRow
If dtActivities Is Nothing Then
ActivityNo = 1
Else
ActivityNo = dtActivities.Rows.Count
End If
drActivities("ActivitiyNo") = ActivityNo + 1
drActivities("ActivityProvided") = pActivityName
dtActivities.Rows.Add(drActivities)

End Sub

Private Sub Combo(ByRef pCombo As ComboBox, ByVal dt As DataTable)
Dim dr As DataRow
If pCombo.Text <> "" Then
dr = dt.NewRow
dr("SupplierNo") = SupplierNo + 1
If CheckExistanceInComboBox(pCombo) = False Then
Call ActivitiesInformation(pCombo.Text)
dr("ActivityNo") = ActivityNo + 1
ElseIf CheckExistanceInComboBox(pCombo) = True Then
dr("ActivityNo") = pCombo.ValueMember
End If
dtSupplierActivities.Rows.Add(dr)

End If
End Sub


Private Sub SupplierActivitesInformation()
Dim drSupplierActivities As DataRow
dtSupplierActivities = DsSupplierActivities1.Tables("SuppliersActivities")
Call Combo(ComboBox1, dtSupplierActivities)

Call Combo(ComboBox2, dtSupplierActivities)
Call Combo(ComboBox3, dtSupplierActivities)
Call Combo(ComboBox4, dtSupplierActivities)
Call Combo(ComboBox5, dtSupplierActivities)
Call Combo(ComboBox6, dtSupplierActivities)
Call Combo(ComboBox7, dtSupplierActivities)
Call Combo(ComboBox8, dtSupplierActivities)
Call Combo(ComboBox9, dtSupplierActivities)
Call Combo(ComboBox10, dtSupplierActivities)
Call Savechanges(dsActivities1, daActivities)
Call Savechanges(DsSupplierActivities1, daSupplierActivities)
End Sub
[/VB]
 
Back
Top