A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access2000: BeforeUpdate for TextBox



 
 
Thread Tools Display Modes
  #1  
Old March 9th, 2010, 02:48 PM posted to microsoft.public.access.forms
Arvi Laanemets
external usenet poster
 
Posts: 397
Default Access2000: BeforeUpdate for TextBox

Hi

On a form I have 2 controls, txtHours & txtMinutes. Whenever there is
entered 60 or more minutes into txtMinutes, I want full hours added to
txtHours (or txtHours value replaced, I haven't decided yet), and set
reminder as new value for txtMinutes. Something like:

Private Sub txtMinutes_BeforeUpdate(Cancel As Integer)
If Me.txtMinutes 60 Then
Else
Me.txtHoues = Me.txtHoues + Int(Me.txtMinutes / 60)
Me.txtMinutes = Me.txtMinutes Mod 60
End If
End Sub


Current code returns an error "The macro or function set to the BeforeUpdate
or ValidationRule property for this field is preventing Microsoft Access
from saving the data in the field." How must this be done?


Thanks in advance!
Arvi Laanemets



  #2  
Old March 9th, 2010, 04:57 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Access2000: BeforeUpdate for TextBox

"Arvi Laanemets" wrote in message
...
Hi

On a form I have 2 controls, txtHours & txtMinutes. Whenever there is
entered 60 or more minutes into txtMinutes, I want full hours added to
txtHours (or txtHours value replaced, I haven't decided yet), and set
reminder as new value for txtMinutes. Something like:

Private Sub txtMinutes_BeforeUpdate(Cancel As Integer)
If Me.txtMinutes 60 Then
Else
Me.txtHoues = Me.txtHoues + Int(Me.txtMinutes / 60)
Me.txtMinutes = Me.txtMinutes Mod 60
End If
End Sub


Current code returns an error "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
Microsoft Access from saving the data in the field." How must this be
done?


You can't change the value of a control in its own BeforeUpdate event. You
must use the control's AfterUpdate event instead.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old March 9th, 2010, 06:17 PM posted to microsoft.public.access.forms
Arvi Laanemets
external usenet poster
 
Posts: 397
Default Access2000: BeforeUpdate for TextBox

Thanks!


"Dirk Goldgar" wrote in message
...

You can't change the value of a control in its own BeforeUpdate event.
You must use the control's AfterUpdate event instead.



This was a surprise for me. It looked logical that all changes must be done
before updating.


Arvi Laanemets


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:46 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.