**AfterUpdate Question** (1 Viewer)

John M

Registered User.
Local time
Today, 05:37
Joined
Nov 20, 2001
Messages
69
Hi,

I have a form that the asks the user to enter "a book id". When he presses the OK button the "book id" is inserted in another open form. But now I want to trigger the AfterUpdate event without any user intervention. How can I do that?
 

Drevlin

Data Demon
Local time
Today, 05:37
Joined
Jul 16, 2002
Messages
135
This depends on what you mean by: No user intervention

It also depends on which OnUpdate your talking about.

If what your saying is that you have code in your second Form's OnUpdate that you want to be called by your first form then you could do one of two things:

1. Remove the Private declaration from your OnUpdate in the second form and call it directly from your first form's code:

'Form1's module
Sub mySub()
doCmd.OpenForm "Form2"
Forms.Form2.Form_OnUpdate
End Sub

'Form2's module
Sub Form_OnUpdate
'Your Code here
End Sub

2. Create a Sub inside your Second Form to call the Private OnUpdate of your second form.

'Form1's Module
Sub mySub()
doCmd.OpenForm "Form2"
Forms.Form2.runOnUpdate
End Sub


'Form2's Module
Sub runOnUpdate()
Form_OnUpdate
End Sub

Private Sub Form_OnUpdate()
'Your Code here
End Sub


I would suggest using the second option.
Of course, I'm not even sure I understood your question so this could be of no help to you whatsoever. ;)

Peace
 

John M

Registered User.
Local time
Today, 05:37
Joined
Nov 20, 2001
Messages
69
Sorry, I meant the "AfterUpdate" event the text field and not the "onupdate" event of the form. I don't know how to trigger the "AfterUpdate" event from the first fiorm.

Thanks.
 

GJT

Registered User.
Local time
Today, 05:37
Joined
Nov 5, 2002
Messages
116
May I ask why you want to invoke the AfterUpdate() event manually?

The AfterUpdate() event in all cases - will only get invoked if the control containing the data, is bound to a table.

:(
 

John M

Registered User.
Local time
Today, 05:37
Joined
Nov 20, 2001
Messages
69
GJT,

The "AfterUpdate" event populates other fields based on the value in the field. For your information, the field does not need to be bound to a table for "AfterUpdate" to work. Thanks for asking.
 
R

Rich

Guest
I think the after update event will only work after manually entering data and not via code, why not simply Requery the form after you've inserted the BookID
 

Users who are viewing this thread

Top Bottom