This is an example of what I am doing using MS Access. I have a table with people names and two text fields for adding telephone numbers. I created a list box with names. I managed to insert selected names from the list box and telephone numbers form the text fields (Tel1 and Tel2) into a table (ContactTable). I used the script as shown below. How can I change this script to use combo box instead of list box.
Private Sub ListBoxEnter_Click()
Dim Name As String
Dim Tel1 As Integer
Dim Tel2 As Integer
If ListBox.ItemsSelected.Count = 1 Then
Name = ListBox.Value
Tel1 = Tel1field
Tel2 = Tel2field
values = "VALUES ("
values = values & "'" & Person_Id & "','" & Name & "','" & Tel1 & "','" & Tel2 & "')"
SQL = "INSERT INTO ContactTable (Person_Id, Name, Tel1, Tel2)"
SQL = SQL & values
DoCmd.RunSQL SQL
Me.Tel1.Value = Null
Me.Tel2.Value = Null
End If
End Sub