S
SAC
I would like to standardize the Not in List event in a module so I can just
call it from a combo box, but I'm not sure how to reference the table and
the current combo box control.
Here's the code I use now:
Response = acDataErrContinue
Dim intAnswer As Integer
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strOldValue As String
Dim strName As String
Dim varCost As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblCustPros", dbOpenDynaset) 'Open the
recordset for the combobox table
intAnswer = MsgBox("Not in File. Add " & NewData & "?", vbQuestion +
vbYesNo) 'Caption of ComboBox
If intAnswer = vbYes Then
With rst
.AddNew
!Name = NewData
.Update
End With
Response = acDataErrAdded ' Requery the combo box list.
Else
Me.Undo
Response = acDataErrContinue ' Require the user to select
' an existing item
End If
Any ideas?
Thanks.
call it from a combo box, but I'm not sure how to reference the table and
the current combo box control.
Here's the code I use now:
Response = acDataErrContinue
Dim intAnswer As Integer
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strOldValue As String
Dim strName As String
Dim varCost As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblCustPros", dbOpenDynaset) 'Open the
recordset for the combobox table
intAnswer = MsgBox("Not in File. Add " & NewData & "?", vbQuestion +
vbYesNo) 'Caption of ComboBox
If intAnswer = vbYes Then
With rst
.AddNew
!Name = NewData
.Update
End With
Response = acDataErrAdded ' Requery the combo box list.
Else
Me.Undo
Response = acDataErrContinue ' Require the user to select
' an existing item
End If
Any ideas?
Thanks.