Hi Guys,
i created simple example database to reproduce error with i am facing off.
On my form i have Group: Men and Women and on subform i have Names and NumberOfPets:
The combobox source is from People.NumberOfPets column.
What i want to do is to update current record with the added item to combobox.
I am using code:
But i am getting error:
How can i solve this?
I suppose that i am editing table right now so i have to leave current row, update table, choose specific value in combobox and return to the specific row.
Am i am thinking properly?
Please help,
Jacek
i created simple example database to reproduce error with i am facing off.
On my form i have Group: Men and Women and on subform i have Names and NumberOfPets:
The combobox source is from People.NumberOfPets column.
What i want to do is to update current record with the added item to combobox.
I am using code:
Code:
Private Sub Combo8_NotInList(NewData As String, Response As Integer)
'MsgBox "ok"
Dim strTmp As String
Dim Result As String
Result = NewData
'Get confirmation that this is not just a spelling error.
strTmp = "Add '" & NewData & "' as a new number?"
If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
strTmp = "Update People SET NumberOfPets = " & NewData & _
" WHERE PeopleID = " & Form_GroupPeopleSubform.PeopleIDFK.Value
' MinInstanceCmb.Value = 1
CurrentDb.Execute strTmp, dbFailOnError
'Notify Access about the new record, so it requeries the combo.
Response = acDataErrAdded
' DoCmd.GoToRecord , , acNext
'DoCmd.RunCommand acCmdSaveRecord
' MinInstanceCmb.Value = Result
'UPDATE someTable SET someDate = Date() WHERE stuff = 47"
End If
End Sub
But i am getting error:
How can i solve this?
I suppose that i am editing table right now so i have to leave current row, update table, choose specific value in combobox and return to the specific row.
Am i am thinking properly?
Please help,
Jacek