Rocky Smolin
rockysmolin at bchacc.com
Tue Nov 2 10:26:11 CDT 2010
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
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Tuesday, November 02, 2010 8:22 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Not In List Event
The field is defined as numeric - double. I could change the field to
percent, but I'll have to change all the downstream calculations to divide
by 100 then, no?
R
-----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:12 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Not In List Event
Hi Rocky
But what is that about percent? If you display percentages, you should enter
18 or 25 or 18.0 or the like.
/gustav
>>> rockysmolin at bchacc.com 02-11-2010 15:26:17 >>>
"That is not possible(?) ..." I agree. That's what I thought when it first
happened. :)
Here's the code from the module:
dblNewVal = Val(NewData)
intReply = MsgBox("The value " & NewData & " is not in the " &
Me.fldBaitPercent.Tag _
& " percent list. Do you want to add it?", vbYesNo)
If intReply = vbNo Then
Response = acDataErrContinue
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
And I just did a copy and paste from your code below just to make sure there
wasn't some subtle difference I was missing. But no luck.
And just to eliminate the possibility that there's something about the form
that's causing it, I created a new form, copied over the combo box, added
the NotInList event code, and got the same result.
Then I thought maybe the combo box has something funny going on in it. So I
created a new combo box on the new form, added the NotInList code, row
source, etc. Same result. It's got to have something to do with the data
because the leading zero makes it work right.
Access...gotta love it...
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 7:19 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Not In List Event
Hi Rocky
That is not possible(?) ...
NewData only appears here:
dblNewVal = Val(NewData)
Did you modify the code in full as shown?
/gustav
>>> rockysmolin at bchacc.com 02-11-2010 14:51:54 >>>
Gustav:
I got the same result.
I unbound the combo box just to eliminate that variable, but no difference.
The format of the combo box is Percent. So I also tried taking that out.
But entering .18 still generates the error message and entering 0.18 works
fine.
Now I should note that after I get the standard error message ("The text you
entered is not an item..."etc) the value I entered is displayed in the combo
box. Although the focus is still on the box. So if I can get rid of that
message, I think everything else would be OK.
TIA
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 12:03 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Not In List Event
Hi Rocky
You probably pass a string that needs to be converted:
rs!fldPercentValue = Val(NewData)
Thus:
dblNewVal = Val(NewData)
intReply = MsgBox("The value " & Format(dblNewVal, "Fixed") & " is not
in the " & Me.fldBaitPercent.Tag _
& " percent list. Do you want to add it?", vbYesNo, "New Value")
If intReply = vbNo Then
Response = acDataErrContinue
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
/gustav
>>> rockysmolin at bchacc.com 02-11-2010 06:02:51 >>>
Jurgen:
I added the dblNewVal = rs!fldPercentValue and Me.fldBaitPercent = dblNewVal
where you indicated:
intReply = MsgBox("The value " & NewData & " is not in the " &
Me.fldBaitPercent.Tag _
& " percent list. Do you want to add it?", vbYesNo)
If intReply = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * FROM tblPercents")
rs.AddNew
rs!fldPercentType = Me.fldBaitPercent.Tag
rs!fldPercentValue = NewData
dblNewVal = rs!fldPercentValue
rs.Update
rs.Close
Set rs = Nothing
Me.fldBaitPercent = dblNewVal
Response = acDataErrAdded
End If
But it made no difference. If I enter a new value like 0.25 is works but if
I enter just .25 it fails.
TIA
Rocky
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com