By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,304 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

When data is added to one form, an "event" must be triggered in another one

100+
P: 547
I use the recordset method to add data to a form called frmchipxc and the table involved is called RaceEntry2. When data is added here, i want to run another function in a subform called "RaceTimingKPSF".The mainform is called "Racesetupxcf". This function deletes duplicate data added in the last 3 minutes to the same table, called "raceentry2" after data has been added.
How do i activate/fire this function in the 2nd form as soon as the table (Raceentry2) receives new data via the "frmchipxc" form. I don't want to use the timer function in the subform as the mouse keeps "flickering" on the main form.
Expand|Select|Wrap|Line Numbers
  1. Dim rs1 As Recordset
  2. Dim myRaceTime As Date, myRaceNo As String, x As Long
  3. DoCmd.SetWarnings False
  4. DoCmd.OpenQuery "DeleteBlankXCEntries"
  5. DoCmd.SetWarnings True
  6. Set rs1 = CurrentDb.OpenRecordset("RaceEntry2", dbOpenDynaset)
  7.  
  8. x = 0
  9. rs1.MoveFirst
  10. With rs1
  11.     Do Until .EOF
  12.         myRaceNo = !RaceNo   'racenumber is a numberfield type
  13.         myRaceTime = !RaceTime
  14.         .MoveNext
  15.             Do Until .EOF
  16.                     If (!RaceNo = myRaceNo) And _
  17.                         (DateDiff("n", myRaceTime, !RaceTime) > -3 And _
  18.                         DateDiff("n", myRaceTime, !RaceTime) < 3) Then
  19.                             .delete
  20.                     End If
  21.                         .MoveNext
  22.             Loop
  23.                 .MoveFirst
  24.                 x = x + 1
  25.                 .Move x
  26.     Loop
  27. End With
  28. rs1.close
  29. Set rs1 = Nothing
  30. 'DoCmd.SetWarnings False
  31.  
  32. [Forms]![Racesetupxcf]![RaceTimingKPSF].Requery
  33. [Forms]![Racesetupxcf]![RaceresultsXCSF].Requery
  34. [Forms]![Racesetupxcf]![SortXcCatSF].Requery
  35. [Forms]![Racesetupxcf]![Rt_editXCSF].Requery
Please assist
Sep 3 '12 #1

✓ answered by TheSmileyCoder

The function must declared as public, and you should then be able to call it like so in the AfterUpdate event of your form:

Expand|Select|Wrap|Line Numbers
  1. Call Forms!Racesetupxcf!ControlNameOfSubFormContainer.Form.FunctionName

Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
The function must declared as public, and you should then be able to call it like so in the AfterUpdate event of your form:

Expand|Select|Wrap|Line Numbers
  1. Call Forms!Racesetupxcf!ControlNameOfSubFormContainer.Form.FunctionName
Sep 3 '12 #2

zmbd
Expert Mod 5K+
P: 5,397
Another way is to treat the forms as class modules; thus, you can create a custom event within the declaration section of the form:

http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

The book "MS Access 2003 Inside and Out" has an example how to do this on page 906 thru 909...

Cool thing here is you can sync any open form to each other by using and declaring the events...

-z
Sep 3 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Sounds a bit like overkill to me. Im sure its usefull but I see no reason going down that road as long as the built in events are fine. Seems you would be re-inventing the wheel so to speak.
Sep 3 '12 #4

100+
P: 547
thx for the help with this problem
Sep 3 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.