G
Guest
I'm not able to stop the system error message box ("The text you entered
isn't an item in the list...") from displaying once the user adds a new price
to the list. What am I doing wrong?
Here's my code:
Private Sub cboCurrentPrice_NotInList(NewData As String, Response As Integer)
Dim rst As Recordset
'Prompt user to verify they wish to add new value.
If MsgBox("Price is not in list. Would you like to add it?", vbOKCancel)
= vbCancel Then
Response = acDataErrContinue
Me.cboCurrentPrice = Me.cboCurrentPrice.ItemData(0)
Else
'add new value to table supporting cbobox
Set rst = CurrentDb.OpenRecordset("tblProductPrices")
With rst
.AddNew
!CatalogNum = Me.CatalogNum
!LotIncrement = 0
!PriceDate = Date
!Price = NewData
.Update
.Close
End With
'inform user of addition
MsgBox "New Price successfully added!", vbExclamation + vbOKCancel,
"New Product Database"
'trigger requery of cbo and stop system err
Response = acDataErrAdded
'clean up memory
Set rst = Nothing
Exit Sub
End If
End Sub
isn't an item in the list...") from displaying once the user adds a new price
to the list. What am I doing wrong?
Here's my code:
Private Sub cboCurrentPrice_NotInList(NewData As String, Response As Integer)
Dim rst As Recordset
'Prompt user to verify they wish to add new value.
If MsgBox("Price is not in list. Would you like to add it?", vbOKCancel)
= vbCancel Then
Response = acDataErrContinue
Me.cboCurrentPrice = Me.cboCurrentPrice.ItemData(0)
Else
'add new value to table supporting cbobox
Set rst = CurrentDb.OpenRecordset("tblProductPrices")
With rst
.AddNew
!CatalogNum = Me.CatalogNum
!LotIncrement = 0
!PriceDate = Date
!Price = NewData
.Update
.Close
End With
'inform user of addition
MsgBox "New Price successfully added!", vbExclamation + vbOKCancel,
"New Product Database"
'trigger requery of cbo and stop system err
Response = acDataErrAdded
'clean up memory
Set rst = Nothing
Exit Sub
End If
End Sub