Public variable passed back to Private Sub

aguest

Registered User.
Local time
Today, 02:42
Joined
Aug 14, 2014
Messages
34
Hi,

i've got a private sub that runs when the form loads. I want it to get the id of the record which has opened this new form.

The public sub populates the variable but it's Empty going back into my private sub. I'm sure its a simple school boy error but it has me stumped!

I want it public as I need to keep that id as new records are added in the form.

Private Sub Form_Load()

FRStudentFundingRequestID
'fundingrequest = FundinRequestID
Me.txtFKFReq = FundingRequest
End Sub
__________________________________
Public Sub FRStudentFundingRequestID()
FundingRequest = [Forms]![frmFundingRequest]![txtpk]
End Sub
 
Why not get it direct?
Code:
Me.txtFKFReq = [Forms]![frmFundingRequest]![txtpk]
 
I did originally but the user can add more than one record to the new form and I wanted to be able to attach all the records until they close the form to the same ID. Hence the public variable.

I've since created it as a subform so have gotten around the actual issue but it would be nice to know how to get the above to work for future reference.

Thanks
 
If it is public or direct set doesn't change anything in this case.
Instead set the default value for the control.
Code:
Me.txtFKFReq.DefaultValue = [Forms]![frmFundingRequest]![txtpk]
 

Users who are viewing this thread

Back
Top Bottom