AfterUpdate Event for TextBox

I have this code for the afterupdate event on a text box that has data in it.

Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
 
When I past this data 0000272400123456 into the text box, it gets rid of the 
0000, becomes 272400123456
 
But if I past this kind of number 4223697600059898, it turns it into this 
42236976000599E+15

If I take the coding away and past the 4223697600059898 number, it stays the 
same and doesn't get changed to the +15.

Any suggestions or changes to code to fix this?

Thanks!

Curtis

0
Utf
12/3/2007 4:24:06 PM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
880 Views

Similar Articles

[PageSpeed] 13

if its a text field then it shouldnt be modifying any values that you enter 
into it - check the field to make sure that its set up as a text field in the 
table and on the form itself

"Curtis Stevens" wrote:

> I have this code for the afterupdate event on a text box that has data in it.
> 
> Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
>  
> When I past this data 0000272400123456 into the text box, it gets rid of the 
> 0000, becomes 272400123456
>  
> But if I past this kind of number 4223697600059898, it turns it into this 
> 42236976000599E+15
> 
> If I take the coding away and past the 4223697600059898 number, it stays the 
> same and doesn't get changed to the +15.
> 
> Any suggestions or changes to code to fix this?
> 
> Thanks!
> 
> Curtis
> 
0
Utf
12/3/2007 5:01:02 PM
Using the Val function turns the string into a number.  Numbers do not have 
leading zeros.  You will need to treat the value in the text box as a string.
-- 
Dave Hargis, Microsoft Access MVP


"Curtis Stevens" wrote:

> I have this code for the afterupdate event on a text box that has data in it.
> 
> Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
>  
> When I past this data 0000272400123456 into the text box, it gets rid of the 
> 0000, becomes 272400123456
>  
> But if I past this kind of number 4223697600059898, it turns it into this 
> 42236976000599E+15
> 
> If I take the coding away and past the 4223697600059898 number, it stays the 
> same and doesn't get changed to the +15.
> 
> Any suggestions or changes to code to fix this?
> 
> Thanks!
> 
> Curtis
> 
0
Utf
12/3/2007 5:08:02 PM
"Curtis Stevens" <CurtisStevens@discussions.microsoft.com> wrote in message 
news:194B2378-9709-4C9A-A4FF-77435EC63011@microsoft.com...
>I have this code for the afterupdate event on a text box that has data in 
>it.
>
> Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
>
> When I past this data 0000272400123456 into the text box, it gets rid of 
> the
> 0000, becomes 272400123456
>
> But if I past this kind of number 4223697600059898, it turns it into this
> 42236976000599E+15
>
> If I take the coding away and past the 4223697600059898 number, it stays 
> the
> same and doesn't get changed to the +15.
>
> Any suggestions or changes to code to fix this?


It's weird to be doing string operations on a number.  What are you actually 
trying to accomplish?  Also, is this text box bound or unbound, if bound 
what is it bound to, and should it always contain a number?

-- 
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

0
Dirk
12/3/2007 5:11:12 PM
Curtis Stevens wrote:

>I have this code for the afterupdate event on a text box that has data in it.
>
>Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
> 
>When I past this data 0000272400123456 into the text box, it gets rid of the 
>0000, becomes 272400123456
> 
>But if I past this kind of number 4223697600059898, it turns it into this 
>42236976000599E+15
>
>If I take the coding away and past the 4223697600059898 number, it stays the 
>same and doesn't get changed to the +15.


That string of digits is too long for the Val function to
convert to a number.  Instead of trying to manipulate the
digits with numeric functions, you should think of it as a
text string.

It looks like all your line of code is doing is deleteing
any dots in the string of digits.  In that case, there is no
reason to use Abs(Val(

OTOH, your code does nothing to prevent a user from entering
non numeric digits, which will also mess up the result of
using Val.

Maybe you have some other unexplained things going on, but I
am having trouble guessing at what objective that code is
attempting to achieve.

-- 
Marsh
MVP [MS Access]
0
Marshall
12/3/2007 6:05:53 PM
Reply:

Similar Artilces:

event firing in Access 2007 (retreat/load events)
I have an 2003 database running under Access 2007. When creating a report, I noticed some anomalies: 1. Retreat event is not fired at all (after a group header is formatted but not printed) 2. Appearently, report Load event fires when I do a print preview, but does not fire when I export to pdf Am I missing something, or is this a bug? Thanks, ...

NDR Event logs 3018 & 3030
Although diagnostic logging for NDR is set to none under the MSExchangeTransport category in Exchange 2003, I still get some event logs 3018 or 3030. Any idea how to get rid of them? These events relate to public folder replication. Check your logging levels under MSExchangeIS\Public Folder -- Tyrone Cowart Microsoft PSS Please do not send email directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. "Claude Wacker" <bcdwacker@hotmail.com> wrote in message news:4d54ffb9.040122...

Event Handler
Hello, I use an COM server that creates a number of events. I have created a class that controls the COM server and that receives the events, it's called LaserCtrl. This works! I have a form that uses LaserCtrl and I want to update a textbox in the form from LaserCtrl. The constructor of LaserCtrl looks like this private TextBox msg; public LaserCtrl(TextBox m) { msg = m; } From a normal method in LaserCtrl this works perfectly msg.Text = "my nice message"; BUT from the EventHandler method nothing happens...

automatically get an alert when someone adds an event to public Calendar?
Is there a way to automatically get an alert when someone adds an event to a public Calendar? Having the person who added the event send me an invite is not an option, because they will not do this. (I am required to check the calendar to see if any events have been added.) I can't see a way to quickly see what new events have been added so I have to check the whole calendar. (Or is there a way to view events by the date they were added, not the date of the event?) TJ There should be some solutions for this at = http://www.slipstick.com/addins/notify.htm=20 --=20 Sue Mosher, Outlook...

Events, dear boy, events #2
Hi Bob Yes I'm certain. I'm right-clicking the worksheet tab to view th sheet's code page, then pasting the in the event code.. -- Gromi ----------------------------------------------------------------------- Gromit's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=92 View this thread: http://www.excelforum.com/showthread.php?threadid=27721 ...

AfterUpdate/BeforeUpdate and SetFocus
I have some problems with the SetFocus command in a Userform with an AfterUpdate or BeforeUpdate routine. To make it clear to you, I made a very small Userform to demonstrate it. It only contains 8 TextBoxes and this code: Code: Private Sub TextBox01_AfterUpdate() Me.TextBox08.SetFocus End Sub - Private Sub TextBox02_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) TextBox08.SetFocus End Sub - Private Sub TextBox03_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox08.SetFocus End Sub - Private Sub TextBox04_Change() TextBox08.SetFocus End Sub I expected that in ...

Meta content in the event log
Hello All Programmer, I want to put Hyperlink in content of Event Log! just like --> For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. this type of hyperlink comes in the content part when windows create the event log message. some buddy told me that this is possible when we send hyperlink in the meta tag. so i want to know that exact procedure... Thanks Ashutosh Hi Ashutosh, We have reviewed this issue and are currently researching on it. We will update you ASAP. Thanks for your patience! regards, Rhett Gong...

CScrollbar events in VS 2003
I've added a scroll bar to a dialog in a new dialog only mfc app. but the only event I can find for it is NM_THEMECHANGED (which throws a compiler error)? Can I add my own WM_SCROLL handlers? Thanks ...

AfterUpdate
Hello Chaps, In the AfterUpdate code I had the detail back colour change if a check box (tbc) = True. However if I tick the box now it turns the back colour of every form irrespective if that record is ticked tbc or not! Any help on solving this would be great. JAMES Private Sub tbc_afterupdate() If Me.tbc = True Then Me.Section(0).BackColor = 65535 Else Me.Section(0).BackColor = 16777215 End If End Sub If you are using a continuous form, that code won't work. The good news is that you can use Conditional Formatting to make it work. In Design View, select the combo box and fro...

Using the onchange event of a picklist to change the label of a fi
I would like to set the Field Lable of a particular field on my form based upon the user's selection of a particular value in a Picklist. Is there any way to use the onchange event to dynamically set the Label of a field on the form? There is no supported way to do this, but if you understand Javascript and DHTML, you can figure out the right section of the form to "update". Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Tue, 16 Aug 2005 23:49:05 -0700, "cdobkins" <cdobkins@discussions.micros...

AfterUpdate Question!
I want to add this to my code , Ony enter date if [DateCheck] (checkbox) is -1 Any help would be great..............Thanks Bob Private Sub tbAdditionCharge_AfterUpdate() If tbDayNo.value = "" Or IsNull(tbDayNo.value) Then tbDayNo.value = Format(Now, "dd-mmm-yy") End If End Sub Hi Bob, Me.tbDayNo=IIf(Me.DateCheck And IsNull(tbDayNo), _ Format(Date,"dd/mm/yy"),tbDayNo) Regards Jacob "Bob V" <rjvance@ihug.co.nz> wrote in message news:%23xApdzD7HHA.4880@TK2MSFTNGP03.phx.gbl... | | I want to add this to my code , Ony enter date if [D...

keyboard event handle problem!
hi all.. in my application i did handling to keyboard using preTranslateMsg because my application is dialog based. i called onKeyUp & onKeyDown inside it to get the necessary parameters cause i want to send them over network.. i also used Keybd_event. but when i integrated it in my application that handles the mouse too using ordinary mouse msgs from the class wizard i have problems in controlling the application. i can`t control the mouse move any more. what`s the problem? The question is too confusing to answer. You don't call OnKeyUp and OnKeyDown; the framework calls them for y...

format chart textbox font
I have a text box linked to a cell in a table in the same workbook. I want to have the font color of the text to reflect that which is in the cell. e.g. I have a dollar figure in the cell. It is in a black front for positive values, and red with parenthese () for negitive figures. At present, I have a negitive dollar figure which reflects in the sheet as a black $(3,813.47). How can I make the font format in the text box follow the spreadsheet's format? Text boxes do not have a number format property. There are two alternative ways to get what you want: Use data labels instead, whi...

BeforeUpdate or AfterUpdate ?
Hi all, I have an unbound form in which I have (amongst others) two comboboxes with mandatory data. Although I present a combobox, limited to the choices to pick out, people manage not to fill in those data and to jump via the TAB-key to the next field. Of course I’ll have NULL value for this combobox, but how can I force the user to look for the correct row ? In the BeforeUpdate or in the AfterUpdate event ? I have some code like : Private Sub CboAfterUpdate() if isnull(me.Cbo) then Beep Msgbox(“You must choose a value”) Me.cboAfter.setfocus endif end sub But this does not se...

restoring deleted Public Folder Calendar events
Is there a way to restore a deleted event from a Public Folder Calendar? Not easily. You can restore the entire database to a recovery server and then use Outlook to move the appointment to a PST and then to the production folder. You might look into OnTrack Power Controls or Quest Recovery Manager, products that might do what you want a whole lot more easily. -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "Pearl" <Pearl@discussions.microsoft.com> wrote in message news:2A523A7D-E9F5-4A1D-A414-4803F65DB8...

Keyboard event bug on 64bit systems
Hi, I have an application that contains the fix described in http://support.microsoft.com/kb/187988. It also uses an ActiveX control that contains the fix described in http://support.microsoft.com/kb/233263. When this application is installed on a 64bit system and certain dialogs are open, keyboard events are received multiple times. So instead of "1" appearing in an edit box "1111" appears. This problem does not appear when the application is run on a 32bit system. I have created a small contrived example that exhibits the same behavior. Here is how to do it: * C...

How to response to the event of dynamically-created and indefinite-number control
I need to dynamically create controls according to the input of user, and reponse to user's operation on these control. For example, when user input 10, I need to create 10 checkbox and reponse to the click event of these checkbox. As far as I know, if the number of control is definite or determined, I can use ordinary message map to satisfy this requirement. But in my project, the number depends on the input of user, and I can not associate a ID with a event I have tried to reponse to the WM_LBUTTONUP message in pretranslatemessage, but to my disgust, when user press the mouse button insi...

AfterUpdate Problem
I need to flash an "RE-ORDER ALERT" message after inventory level falls below re-order level. The message only flashes up when I move to a next record and back after a DoCmd.Save. I need the message to flash immediate after a Save. Note. The message is a flashing label on the form. Thank you. Perhaps you could code it to actually flash before DoCmd.Save is processed. Once you're into that code string, it will be run. Or, maybe consider a Message Box. I like this idea because it forces the user to interact with the reorder message. No one can say "I didn'...

which event?
Hi friends, I just wanted to know which event is triggered whebn someone deletes or modifies only a single occurance of a recurring appointment. I tried to catch the itemremove and itemchange events but they are not triggered when only one occurence is changed. So could anyone please help in this regard. Thank you... ...

reinstall Exchange Event Service
Hi, I have a problem to reinstall Exchange Event Service. I am using Exchange 5.5. I want to reinstall exchange event service because it causes some errors. I removed the exchange event service using exchange 5.5 setup program and I applied SP4 immediately. It causes the exchange event service is installed (I found it is in the services MMC and still exist after reboot). So I added the exchange event service using exchange 5.5 setup program but I got an error when started the service. An unexpected MAPI error occured. Error returned was [0x80004005] I tried to remove the exchange event serv...

How do I stop a Textbox in a Userform converting numbers?
Probably a really stupid question... but how do I stop a Textbox on userform from removing the leading zero on a number? eg 01234567890 becomes 123456789 -- Message posted from http://www.ExcelForum.com Alan You must format the cell first as text. e.g Private Sub CommandButton1_Click() Range("A6").NumberFormat = "@" Range("A6").Value = TextBox1.Text End Sub Regards Peter >-----Original Message----- >Probably a really stupid question... but how do I stop a Textbox on a >userform from removing the leading zero on a number? > >eg 01234...

ribbon and event
I have created a custon ribbon with Custon Ui Editor for a .xlam file. It seems work fine. Is it need write something in ThisWorkbook module in Workbook_Open and Workbook_BeforeClose event like a custon bar in excel 2003? Or add something other in file? thx You open the workbook that you want to install it in within the Custom UI editor, and then save it. The ribbon extension gets saved with the workbook, in a file called customUI.xml. Thus it will be available next time. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Ma...

Event ID 9519
This is a multi-part message in MIME format. --------------050203000205000406030504 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello Newsgroup, I'm having a bit of a challenge here. I'm trying to assist a colleague with the following issue. They have a *Windows 2000 server* and a *Exchange Server 2000 Standard* setup. Everything is working fine except that the Exchange server server crashed for reasons that they cannot say. Now I went through and did a *eseutil /mh /r /k /g* and then unfortunately a */p*. Doing all of that brough...

Publisher-Calendar-re-occuring events
How do I have an event carry over to a new calendar without copy and paste? Copy and Paste, or use a database and Merge the information. -- ...

Capture event when exit Column G
I want to code something whenever there's a change in Column G/8. Some users use the Mouse, others use the Tab, others use the Enter key, so it isn't just a Target.Column=9 deal. Would someone please start me in the right direction for coding on exit of a cell in Column G/8? TIA Hi I'd use the slection_change event. Put the following code in your worksheet module: (Note: column G ist the 7th column) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static old_column As Integer If Target.Column <> 7 Then If old_column = 7 Then MsgBox "you jus...