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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
[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
|
|||
|
|||
[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
|
|||
|
|||
[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
|
|||
|
|||
[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 | |
|
|