CompanyTesterVlad.zip
Good morning all,
I just ran into an error testing out a NotInList event which i have used a lot over time with no issues.
So while testing this out it is asking me to declare a varible? What varible is not decared all ready?
Code:
Private Sub CboLocationType_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer
x = MsgBox("Location Name is Not in Current List, Would you Like to Add?", vbYesNo)
If x = vbYes Then
strsql = "INSERT INTO tblHelper (HelperTypeID, HelperValue) " & _
"VALUES (" & CboLocationType & ", '" & NewData & "')"
'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
I dont get why this creates an error. I have the same code in many db's and it works fine!!!!
What have I not done correctly?
Update: OK, I see where I beleive the issue is and its in the rowsource of the CboLocationType.
So, Instead of putting the Cbo in that i put "1" in and it works. Not sure if this is the correct way
to do so but see new code.
Code:
Private Sub CboLocationType_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer
x = MsgBox("Location Name is Not in Current List, Would you Like to Add?", vbYesNo)
If x = vbYes Then
strsql = "INSERT INTO tblHelper (HelperTypeID, HelperValue) " & _
"VALUES (" & 1 & ", '" & NewData & "')"
'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
Thanks
Dave