Hi Everyone
I'm struggling with this code to add an item to a table which feeds a combo list
The underlying table is called Addq, the current form is called Questionentryform
It seems to add the number to the values in the addq table (but I cant tell when) because if you click add a second time it then tells you that duplicates are not allowed.
The pop up asks me if i want to add the value then asks me over again without adding the value to the combo list.
I've tried refreshing, requery, setting the keyword values to nothing etc. Please help I've been scouring code for help for the past 4 days
Thanks
Sarah
P.s. I'm a novice at code writing so please make the explination simple, the xtra at the end of the coding is stuff i've already tried
Private Sub QuestionNumber_NotInList(NewData As String, Response As Integer)
'Adds a question number that is not in the list to the list, if the user wishes to do so.
Dim strMessage As String
Dim intAnswer As Integer
strMessage = "'" & [NewData] & "' is currently not in your list. Do you wish to add it?"
intAnswer = MsgBox(strMessage, vbOKCancel + vbQuestion)
If intAnswer = 1 Then
Set dbsVBA = CurrentDb
Set rstKeyWord = dbsVBA.OpenRecordset("Addq")
With rstKeyWord
.AddNew
!QuestionNumber = [NewData]
.Update
End With
'rstKeyWord.Close
'Refresh.QuestionNumberlist
'Me.Refresh
'Refresh
'Set rstKeyWord = Nothing
'Me.QuestionNumberlist.Requery
'DoCmd.Requery
Response = acDataErrAdded
Response = acDataErrDisplay
End If
End Sub
I'm struggling with this code to add an item to a table which feeds a combo list
The underlying table is called Addq, the current form is called Questionentryform
It seems to add the number to the values in the addq table (but I cant tell when) because if you click add a second time it then tells you that duplicates are not allowed.
The pop up asks me if i want to add the value then asks me over again without adding the value to the combo list.
I've tried refreshing, requery, setting the keyword values to nothing etc. Please help I've been scouring code for help for the past 4 days
Thanks
Sarah
P.s. I'm a novice at code writing so please make the explination simple, the xtra at the end of the coding is stuff i've already tried
Private Sub QuestionNumber_NotInList(NewData As String, Response As Integer)
'Adds a question number that is not in the list to the list, if the user wishes to do so.
Dim strMessage As String
Dim intAnswer As Integer
strMessage = "'" & [NewData] & "' is currently not in your list. Do you wish to add it?"
intAnswer = MsgBox(strMessage, vbOKCancel + vbQuestion)
If intAnswer = 1 Then
Set dbsVBA = CurrentDb
Set rstKeyWord = dbsVBA.OpenRecordset("Addq")
With rstKeyWord
.AddNew
!QuestionNumber = [NewData]
.Update
End With
'rstKeyWord.Close
'Refresh.QuestionNumberlist
'Me.Refresh
'Refresh
'Set rstKeyWord = Nothing
'Me.QuestionNumberlist.Requery
'DoCmd.Requery
Response = acDataErrAdded
Response = acDataErrDisplay
End If
End Sub