L
Lily
I have a form with two cascading combo boxes. The first one is the 50 states
in the U.S., the second one is the corresponding counties in the state that
is selected in the first combo box. Users want an option of adding a venue to
the county combo box when it is not in the list. I have code in NotInList
event of cboCounty:
Private Sub cboCounty_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & " 'is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Venue...")
If i = vbYes Then
strSQL = "Insert Into tblCounty ([State],[County]) values (Me.State,'" &
NewData & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
When I add a new value to cboCounty, I have the following error message:
Run-time error: 3061
Too few parameters. Expect 1
On command "CurrentDb.Execute strSQL, dbFailOnError "
What is wrong? Please help. Thanks in advance
in the U.S., the second one is the corresponding counties in the state that
is selected in the first combo box. Users want an option of adding a venue to
the county combo box when it is not in the list. I have code in NotInList
event of cboCounty:
Private Sub cboCounty_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & " 'is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Venue...")
If i = vbYes Then
strSQL = "Insert Into tblCounty ([State],[County]) values (Me.State,'" &
NewData & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
When I add a new value to cboCounty, I have the following error message:
Run-time error: 3061
Too few parameters. Expect 1
On command "CurrentDb.Execute strSQL, dbFailOnError "
What is wrong? Please help. Thanks in advance