R
robingSA
Hi...I have a number of Combo Boxes on a form. If one types a name
which is not in the table, I want it to add the typed, new item. I am
using the following code to do this and it works well, except for one
thing - each new item is added as a new record. I want the new name to
be added after the last entry in the relevant field...is this possible
- preferably by tweaking the code I am using already?
Private Sub Supermarket_NotInList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Businesses", dbOpenDynaset)
Rs.AddNew
Rs![Supermarket] = NewData
Rs.Update
Response = acDataErrAdded
End If
End Sub
Thanks...Rob
which is not in the table, I want it to add the typed, new item. I am
using the following code to do this and it works well, except for one
thing - each new item is added as a new record. I want the new name to
be added after the last entry in the relevant field...is this possible
- preferably by tweaking the code I am using already?
Private Sub Supermarket_NotInList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Businesses", dbOpenDynaset)
Rs.AddNew
Rs![Supermarket] = NewData
Rs.Update
Response = acDataErrAdded
End If
End Sub
Thanks...Rob