UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> After Update Trigger, Access 2013    
 
   
waitingroomz
post Oct 2 2019, 09:14 AM
Post#1



Posts: 93
Joined: 29-October 18



I need to fire an After Update event for a Control on a main form once a variable is passed to it from a subform, but want the code to be used variably.

AfterUpdate on Main Form:

CODE
Public Sub cboPatientID_AfterUpdate()
     DoCmd.SearchForRecord , , acFirst, "[PatientID]=" & Str(Nz(Me.cboPatientID, 0))
End Sub


MouseDown Event on Subform:

CODE
Private Sub cmdSelect_MouseDown()
     PassSubFormID "cboPatientID", Me.txtRef.Value
End Sub


Module:

CODE
Public Sub PassSubFormID(strCtrl As String, myVar as Variant)
     Forms(Screen.ActiveForm.Name.Controls(strCtrl) = myVar
'''''''WHERE I NEED THE AFTERUPDATE TO OCCUR FOR THE SAME CONTROL 'myVar' WAS PASSED TO.
End Sub

This post has been edited by waitingroomz: Oct 2 2019, 09:15 AM
Go to the top of the page
 
arnelgp
post Oct 2 2019, 10:37 AM
Post#2



Posts: 1,510
Joined: 2-April 09
From: somewhere out there...


CODE
Public Sub PassSubFormID(strCtrl As String, myVar as Variant)
     Dim frm As Form
     Set frm = Screen.ActiveForm
     frm.Controls(strCtrl) = myVar
     frm.cboPatientID_AfterUpdate
End Sub

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
waitingroomz
post Oct 2 2019, 10:40 AM
Post#3



Posts: 93
Joined: 29-October 18



Thanks, however, I need the strCtrl to pass the strCtrl_AfterUpdate event I'm looking form.
Go to the top of the page
 
arnelgp
post Oct 2 2019, 11:46 AM
Post#4



Posts: 1,510
Joined: 2-April 09
From: somewhere out there...


why making it so hard, when you can do it the easier way.

Eval wont work.
CallByName wont work.

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
arnelgp
post Oct 2 2019, 12:57 PM
Post#5



Posts: 1,510
Joined: 2-April 09
From: somewhere out there...


CODE
Public Sub PassSubFormID(strCtrl As String, myVar as Variant)
     Dim frm As Form
     Set frm = Screen.ActiveForm
     frm.Controls(strCtrl) = myVar
     CallByName frm, strCtrl & "_AfterUpdate", vbMethod
End Sub

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
waitingroomz
post Oct 2 2019, 01:34 PM
Post#6



Posts: 93
Joined: 29-October 18



It responds with Error #2465 Application-Define or Object-Defined Error

But this is exactly the type of thought I was looking for.
Go to the top of the page
 
dmhzx
post Oct 4 2019, 12:10 PM
Post#7



Posts: 7,112
Joined: 22-December 10
From: England


I have a couple of questions here trying to understand what you're trying to do.

It looks as though you're trying to do something when a patient ID changes in various different places.
me.findfirst should work at form level.

PatientID is surely not a string? (else why would you want to convert it to one?)

If you want afterupdate to trigger you need to call it specifically.


Are you sure you want something done on Mousedown..

And finally, a public variable declared at form level might make things easier (but is unfashionable)

For example if you make a Public daclaration at from level of "lPateintID" (if it's a number) or strPatientID if a string, then you can at each of your trigger points cal a common sub to call whatever other things you want to do.

Not sure if that actually helps.



Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    11th November 2019 - 03:25 PM