I have a combo box connect to an acces db. If the user types something in the combo box that is not in the list, I wanted to have a msgbox popup & ask them if they want to add it.
Here is my code. I keep getting compile errors on the execute statement. I'm sure that I am doing this all wrong.
Thanks,
Vwalla
Here is my code. I keep getting compile errors on the execute statement. I'm sure that I am doing this all wrong.
Code:
Private Sub cboCat_LostFocus()
Dim db As New Connection
Set db = New Connection
If adoPrimaryRS.EOF Then
'Value does exist in database, ask user if they would like to add value
If MsgBox("Add Value", vbYesNo + vbQuestion, "Add Value") = vbYes Then
adoPrimaryRS.Open "select * from cat WHERE category='" & Replace(cboCat.Text, "'", "''") & "'", db, adOpenStatic, adLockOptimistic
db.Execute "INSERT INTO Cat VALUES('" & cboCat.Text & "'),,adCmdText"
End If
End If
adoPrimaryRS.MoveNext
adoPrimaryRS.Close
End Sub]
Thanks,
Vwalla