Rocky Smolin
rockysmolin at bchacc.com
Tue Nov 2 11:22:13 CDT 2010
BTW, since there are four of these combo boxes with four different percents to store, I put the update in a function: Private Function NotInListFunction(argTag As String, argNewData As String) As Boolean 'dblNewVal = Val(argNewData) dblNewVal = Val(argNewData) / 100 intReply = MsgBox("The value " & dblNewVal & " is not in the " _ & argTag _ & " percent list. Do you want to add it?", vbYesNo, "New Value") If intReply = vbNo Then NotInListFunction = False Else Set db = CurrentDb Set rs = db.OpenRecordset("Select Top 1 * FROM tblPercents") rs.AddNew rs!fldPercentType = argTag rs!fldPercentValue = dblNewVal rs.Update rs.Close Set rs = Nothing NotInListFunction = True End If End Function And call it like this: Private Sub cboBaitPercent_NotInList(NewData As String, Response As Integer) If NotInListFunction(Me.cboBaitPercent.Tag, NewData) = False Then Response = acDataErrContinue Me.cboBaitPercent.Undo Else Me.cboBaitPercent = dblNewVal Response = acDataErrAdded End If End Sub Seems to work OK except of course for the original problem. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Tuesday, November 02, 2010 8:44 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Not In List Event Hi Rocky OK, that explains. Now use this: dblNewVal = Val(NewData) / 100 intReply = MsgBox("The value " & Format(dblNewVal, "Percent") & " is not in the " & Me.fldBaitPercent.Tag _ & " percent list. Do you want to add it?", vbYesNo, "New Value") If intReply = vbNo Then Response = acDataErrContinue ' <NameOfYourComboBox>.Undo Else Set db = CurrentDb Set rs = db.OpenRecordset("Select Top 1 * FROM tblPercents") rs.AddNew rs!fldPercentType = Me.fldBaitPercent.Tag rs!fldPercentValue = dblNewVal rs.Update rs.Close Set rs = Nothing Me.fldBaitPercent = dblNewVal Response = acDataErrAdded End If That works here. /gustav >>> rockysmolin at bchacc.com 02-11-2010 16:26:11 >>> I changed the format of the combo box to Percent but when I enter 26 it comes out as 2600% instead of 26%. And gets stored in the table as 26 instead of .26 R -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com