wedd
11-22-2011, 08:25 AM
Hi experts, I've witten the following code to add a new item to a combo box. However, I keep receiving the following runtime error 3134.Why does this error keep appearing when I run it? In addition, whenever I click on other buttons on my form a popup message box appears asking if I want to add a new item. How can I prevent this from happening? The code is listed below. Thanks for your contributions.:friends:
Private Sub CboLocations_NotInList(NewData As String, Response As Integer) Dim strTmp As String
'Get confirmation that this is not just a spelling error.
strTmp = "Add '" & NewData & "' as a new Venue?"
If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
'Append the NewData as a record in the Check Availability table.
strTmp = "INSERT INTO Check Availability ( Venue ) " & _
"SELECT """ & NewData & """ AS Venue;"
DBEngine(0)(0).Execute strTmp, dbFailOnError
'Notify Access about the new record, so it requeries the combo.
Response = acDataErrAdded
End If
I get an error with this part of my code: How can I rectify this?
'Append the NewData as a record in the Categories table.
strTmp = "INSERT INTO Check_Availability ( Venue ) " &
"SELECT """ & NewData & """ AS Venue;"
Private Sub CboLocations_NotInList(NewData As String, Response As Integer) Dim strTmp As String
'Get confirmation that this is not just a spelling error.
strTmp = "Add '" & NewData & "' as a new Venue?"
If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
'Append the NewData as a record in the Check Availability table.
strTmp = "INSERT INTO Check Availability ( Venue ) " & _
"SELECT """ & NewData & """ AS Venue;"
DBEngine(0)(0).Execute strTmp, dbFailOnError
'Notify Access about the new record, so it requeries the combo.
Response = acDataErrAdded
End If
I get an error with this part of my code: How can I rectify this?
'Append the NewData as a record in the Categories table.
strTmp = "INSERT INTO Check_Availability ( Venue ) " &
"SELECT """ & NewData & """ AS Venue;"