F
forest8
Hi there
I'm trying to see what I'm doing wrong with this NotInList code.
In my T_Programs (table called Programs), I have a Coach field which is
populated by a Combo Box that I created in a separated table called CB_Coach.
Private Sub Coach_NotInList(NewData As String, Response As Integer)
intAnswer = MsgBox("This coach" & NewData & " is not currently in the list."
& vbCrLf & _
"Would you like to add this coach to the list now?" _
, vbQuestion + vbYesNo, "This coach")
If intAnswer = vbYes Then
strSQL = "INSERT INTO CB_Coach([CB_Coach]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "This coach has been added to the list." _
, vbInformation, "NewData"
Response = acDataErrAdded
End If
End Sub
At first, I couldn't add a new coach. But then I did the following:
Column Count 2
Column Widths 0
Bound Column 2
Limit to List No
Allow Value List Edits Yes
Inherit List Value Yes
Now I can put a new name in the field but it's not added to the CB_Coach
table.
What am I doing wrong?
Thank you in advance.
I'm trying to see what I'm doing wrong with this NotInList code.
In my T_Programs (table called Programs), I have a Coach field which is
populated by a Combo Box that I created in a separated table called CB_Coach.
Private Sub Coach_NotInList(NewData As String, Response As Integer)
intAnswer = MsgBox("This coach" & NewData & " is not currently in the list."
& vbCrLf & _
"Would you like to add this coach to the list now?" _
, vbQuestion + vbYesNo, "This coach")
If intAnswer = vbYes Then
strSQL = "INSERT INTO CB_Coach([CB_Coach]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "This coach has been added to the list." _
, vbInformation, "NewData"
Response = acDataErrAdded
End If
End Sub
At first, I couldn't add a new coach. But then I did the following:
Column Count 2
Column Widths 0
Bound Column 2
Limit to List No
Allow Value List Edits Yes
Inherit List Value Yes
Now I can put a new name in the field but it's not added to the CB_Coach
table.
What am I doing wrong?
Thank you in advance.