Hello,
I have a combo box on a subform that when i enter a value that is not in the list. it adds the value to the table that holds the values in the combo box. This part works fine.
But i still recieve the message that the value is not in the list. I think this is because the query that runs to display the apropriate values in the combo box needs to be requeried.
As such at the end of my code i have placed a requeary command for the control. When i do this i am informed that i must save the control first.
I hope someone can help me solve this sticky problem.
Here is the code for the Not in List action.
My Main form is called [View Reps] and my subform is called [Questionaire]
Private Sub ResponseT_NotInList(NewData As String, Response As Integer)
Dim respt As String
Dim quest As String
Dim stDt As Date
Dim enDt As Date
Dim sSQL As String
respt = ResponseT.Text
quest = Me.Question
stDt = DLookup("[DT_START]", "tbl_QAR", "[Question]=" & Chr(34) & quest & Chr(34))
enDt = DLookup("[DT_END]", "tbl_QAR", "[Question]=" & Chr(34) & quest & Chr(34))
sSQL = "INSERT INTO tbl_QAR ( Question, ResponseT, DT_START, DT_END ) " & _
"VALUES (" & Chr(34) & quest & Chr(34) & ", " & Chr(34) & respt & Chr(34) & ", " & _
Chr(34) & stDt & Chr(34) & ", " & Chr(34) & enDt & Chr(34) & ") ;"
DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True
ResponseT.Requery
End Sub
Many thanks Craig.