PDA

View Full Version : I keep receiving this runtime error 3134 - why does it keep appearing?



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;"

orange
11-22-2011, 06:38 PM
Do a debug.print on strTemp and confirm what Access is actually using.
Post back what you find.

wedd
11-23-2011, 03:49 AM
Ok. I'll run a debug test and let you know...

wedd
11-23-2011, 06:30 AM
Hi, Orange! I ran the code with a debug to test it and I received a compile error: variable not define even though I have an option explicit to declare the variable. Have you an ideas how I can resolve this issue? Thanks!

orange
11-23-2011, 07:33 AM
Sorry it should be strTmp

wedd
11-23-2011, 07:44 AM
Hi Orange, I ran the debug.print on strtmp and received a compile error message: variable not defined...

hmmm not sure whats causing this error...have you an idea what could be the issue? Thanks

wedd
11-23-2011, 09:49 AM
Hi Orange! Where I've highlighted the bold lines in the code is this the correct way to apply the debug.print? Or should it be written differntly? I've written it as Debug.Print strTmp. Thanks!


Private Sub Locations_NotInList(NewData As String, Response As Integer)
'Get confirmation that this is not just a spelling error.
Debug.Print strTmp; 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.
Debug.print strTmp; 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

End Sub