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  

[Modules] Updating Calculated Fields ?



 
 
Thread Tools Display Modes
  #1  
Old June 15th, 2004, 05:01 PM
Nico
external usenet poster
 
Posts: n/a
Default [Modules] Updating Calculated Fields ?

Hi all,

I have several calculated fields (yeah, well I know it's wrong but anyway) I want to update after the 'Source Controls' changed. Well, one source fields actually updates several fields. So I wrote in the 'AfterUpDate' Event almost 30 lines to update all my calculated fields. Then I copy/pasted over the other After Update Events of my other source fields.
Then I asked myself : can't I wrote that Sub in a Module and just 'Call' it in the AfterUpDate Event ? But I didn't manage ! Access keeps not recognizing my Sub.
What are the points I missed ? Or the procedure I should follow ?

To be more precise, I wrote something like this :

in my txtSourceField1, in the AfterUpdate Event :
form![frm FormName]![txtCalculatedField1]= blah blah 'which worked

then I copy/pasted it to a 'mod General' Module, creating an 'UpdateCalculatedFields' Sub, containing the same code. In the AfterUpdate Event, I put something like :
Call UpdateCalculatedFields() 'which didn't work !

Any Help Would be apreciated !

Nico
  #2  
Old June 15th, 2004, 05:41 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default [Modules] Updating Calculated Fields ?

"Nico" wrote in message

Hi all,

I have several calculated fields (yeah, well I know it's wrong but
anyway) I want to update after the 'Source Controls' changed. Well,
one source fields actually updates several fields. So I wrote in the
'AfterUpDate' Event almost 30 lines to update all my calculated
fields. Then I copy/pasted over the other After Update Events of my
other source fields. Then I asked myself : can't I wrote that Sub in
a Module and just 'Call' it in the AfterUpDate Event ? But I didn't
manage ! Access keeps not recognizing my Sub.
What are the points I missed ? Or the procedure I should follow ?

To be more precise, I wrote something like this :

in my txtSourceField1, in the AfterUpdate Event :
form![frm FormName]![txtCalculatedField1]= blah blah 'which
worked

then I copy/pasted it to a 'mod General' Module, creating an
'UpdateCalculatedFields' Sub, containing the same code. In the
AfterUpdate Event, I put something like :
Call UpdateCalculatedFields() 'which didn't work !

Any Help Would be apreciated !

Nico


Is your UpdateCalculateFields sub defined in the module as

Public Sub UpdateCalculateFields ()

or as

Private Sub UpdateCalculateFields ()

? It must be public.

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

(please reply to the newsgroup)


  #3  
Old June 16th, 2004, 09:11 AM
Nico
external usenet poster
 
Posts: n/a
Default [Modules] Updating Calculated Fields ?

Hi Dirk,

Yes, I have declared it public. I tryed to set it as a 'Function' using a Boolean, or a 'Sub', but it didn't work.
The Sub in the AfterUpDate Event is like :

Private Sub txtSourceField_AfterUpDate()

Call UpdateCalculateFields
End Sub
_____
With the UpdateCalculateFields Sub set in my Module


Public Sub UpdateCalculateFields()

form![frm FormName]![txtCalculatedField1]= blah blah
....
End Sub
____

Access says that it doesn't recognize the user function, on a MsgBox displayed when it should be calculating the fields. I guess I missed a point in declaration or in name of the different object and the links... But where ?

Thanks





"Dirk Goldgar" wrote:

"Nico" wrote in message

Hi all,

I have several calculated fields (yeah, well I know it's wrong but
anyway) I want to update after the 'Source Controls' changed. Well,
one source fields actually updates several fields. So I wrote in the
'AfterUpDate' Event almost 30 lines to update all my calculated
fields. Then I copy/pasted over the other After Update Events of my
other source fields. Then I asked myself : can't I wrote that Sub in
a Module and just 'Call' it in the AfterUpDate Event ? But I didn't
manage ! Access keeps not recognizing my Sub.
What are the points I missed ? Or the procedure I should follow ?

To be more precise, I wrote something like this :

in my txtSourceField1, in the AfterUpdate Event :
form![frm FormName]![txtCalculatedField1]= blah blah 'which
worked

then I copy/pasted it to a 'mod General' Module, creating an
'UpdateCalculatedFields' Sub, containing the same code. In the
AfterUpdate Event, I put something like :
Call UpdateCalculatedFields() 'which didn't work !

Any Help Would be apreciated !

Nico


Is your UpdateCalculateFields sub defined in the module as

Public Sub UpdateCalculateFields ()

or as

Private Sub UpdateCalculateFields ()

? It must be public.

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

(please reply to the newsgroup)



  #4  
Old June 16th, 2004, 10:31 AM
Nico
external usenet poster
 
Posts: n/a
Default [Modules] Updating Calculated Fields ?

Well, nevermind

I copyed my forms, well, all my fields, and put the code back in order, and it worked !
Just called my public Sub in my event...
It's a mystery !

Thanks for your help !

See ya around !
Nico





"Nico" wrote:

Hi all,

I have several calculated fields (yeah, well I know it's wrong but anyway) I want to update after the 'Source Controls' changed. Well, one source fields actually updates several fields. So I wrote in the 'AfterUpDate' Event almost 30 lines to update all my calculated fields. Then I copy/pasted over the other After Update Events of my other source fields.
Then I asked myself : can't I wrote that Sub in a Module and just 'Call' it in the AfterUpDate Event ? But I didn't manage ! Access keeps not recognizing my Sub.
What are the points I missed ? Or the procedure I should follow ?

To be more precise, I wrote something like this :

in my txtSourceField1, in the AfterUpdate Event :
form![frm FormName]![txtCalculatedField1]= blah blah 'which worked

then I copy/pasted it to a 'mod General' Module, creating an 'UpdateCalculatedFields' Sub, containing the same code. In the AfterUpdate Event, I put something like :
Call UpdateCalculatedFields() 'which didn't work !

Any Help Would be apreciated !

Nico

 




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 04:44 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.